提交 ab0da52b 编写于 作者: D Daniel P. Berrange

Convert monitor over to use virDomainDeviceAddress

Convert the QEMU monitor APIs over to use virDomainDeviceAddress
structs for passing addresses in/out, instead of individual bits.
This makes the number of parameters smaller & easier to deal with.
No functional change

* src/qemu/qemu_driver.c, src/qemu/qemu_monitor.c,
  src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_text.c,
  src/qemu/qemu_monitor_text.h: Change monitor hotplug APIs to
  take an explicit address ptr for all host/guest addresses
上级 8d6af63a
......@@ -5093,6 +5093,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
int i, ret;
const char* type = virDomainDiskBusTypeToString(dev->data.disk->bus);
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDevicePCIAddress guestAddr;
for (i = 0 ; i < vm->def->ndisks ; i++) {
if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst)) {
......@@ -5111,13 +5112,12 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
ret = qemuMonitorAddPCIDisk(priv->mon,
dev->data.disk->src,
type,
&dev->data.disk->info.addr.pci.domain,
&dev->data.disk->info.addr.pci.bus,
&dev->data.disk->info.addr.pci.slot);
&guestAddr);
qemuDomainObjExitMonitorWithDriver(driver, vm);
if (ret == 0) {
dev->data.disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
memcpy(&dev->data.disk->info.addr.pci, &guestAddr, sizeof(guestAddr));
virDomainDiskInsertPreAlloced(vm->def, dev->data.disk);
}
......@@ -5174,6 +5174,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
char *nicstr = NULL;
char *netstr = NULL;
int ret = -1;
virDomainDevicePCIAddress guestAddr;
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_HOST_NET_ADD)) {
qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, "%s",
......@@ -5242,13 +5243,12 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuMonitorAddPCINetwork(priv->mon, nicstr,
&net->info.addr.pci.domain,
&net->info.addr.pci.bus,
&net->info.addr.pci.slot) < 0) {
&guestAddr) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
goto try_remove;
}
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr));
qemuDomainObjExitMonitorWithDriver(driver, vm);
ret = 0;
......@@ -5300,6 +5300,7 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn,
virDomainHostdevDefPtr hostdev = dev->data.hostdev;
pciDevice *pci;
int ret;
virDomainDevicePCIAddress guestAddr;
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
virReportOOMError(conn);
......@@ -5327,17 +5328,13 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorAddPCIHostDevice(priv->mon,
hostdev->source.subsys.u.pci.domain,
hostdev->source.subsys.u.pci.bus,
hostdev->source.subsys.u.pci.slot,
hostdev->source.subsys.u.pci.function,
&hostdev->info.addr.pci.domain,
&hostdev->info.addr.pci.bus,
&hostdev->info.addr.pci.slot);
&hostdev->source.subsys.u.pci,
&guestAddr);
qemuDomainObjExitMonitorWithDriver(driver, vm);
if (ret < 0)
goto error;
hostdev->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
memcpy(&hostdev->info.addr.pci, &guestAddr, sizeof(guestAddr));
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
......@@ -5576,9 +5573,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuMonitorRemovePCIDevice(priv->mon,
detach->info.addr.pci.domain,
detach->info.addr.pci.bus,
detach->info.addr.pci.slot) < 0) {
&detach->info.addr.pci) < 0) {
qemuDomainObjExitMonitor(vm);
goto cleanup;
}
......@@ -5648,9 +5643,7 @@ qemudDomainDetachNetDevice(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuMonitorRemovePCIDevice(priv->mon,
detach->info.addr.pci.domain,
detach->info.addr.pci.bus,
detach->info.addr.pci.slot) < 0) {
&detach->info.addr.pci) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
goto cleanup;
}
......@@ -5737,9 +5730,7 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuMonitorRemovePCIDevice(priv->mon,
detach->info.addr.pci.domain,
detach->info.addr.pci.bus,
detach->info.addr.pci.slot) < 0) {
&detach->info.addr.pci) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
return -1;
}
......
......@@ -1117,33 +1117,18 @@ int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon,
int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
unsigned hostDomain,
unsigned hostBus,
unsigned hostSlot,
unsigned hostFunction,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot)
virDomainDevicePCIAddress *hostAddr,
virDomainDevicePCIAddress *guestAddr)
{
int ret;
DEBUG("mon=%p, fd=%d domain=%d bus=%d slot=%d function=%d",
mon, mon->fd,
hostDomain, hostBus, hostSlot, hostFunction);
hostAddr->domain, hostAddr->bus, hostAddr->slot, hostAddr->function);
if (mon->json)
ret = qemuMonitorJSONAddPCIHostDevice(mon, hostDomain,
hostBus, hostSlot,
hostFunction,
guestDomain,
guestBus,
guestSlot);
ret = qemuMonitorJSONAddPCIHostDevice(mon, hostAddr, guestAddr);
else
ret = qemuMonitorTextAddPCIHostDevice(mon, hostDomain,
hostBus, hostSlot,
hostFunction,
guestDomain,
guestBus,
guestSlot);
ret = qemuMonitorTextAddPCIHostDevice(mon, hostAddr, guestAddr);
return ret;
}
......@@ -1151,58 +1136,47 @@ int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
const char *path,
const char *bus,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot)
virDomainDevicePCIAddress *guestAddr)
{
int ret;
DEBUG("mon=%p, fd=%d path=%s bus=%s",
mon, mon->fd, path, bus);
if (mon->json)
ret = qemuMonitorJSONAddPCIDisk(mon, path, bus,
guestDomain, guestBus, guestSlot);
ret = qemuMonitorJSONAddPCIDisk(mon, path, bus, guestAddr);
else
ret = qemuMonitorTextAddPCIDisk(mon, path, bus,
guestDomain, guestBus, guestSlot);
ret = qemuMonitorTextAddPCIDisk(mon, path, bus, guestAddr);
return ret;
}
int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
const char *nicstr,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot)
virDomainDevicePCIAddress *guestAddr)
{
int ret;
DEBUG("mon=%p, fd=%d nicstr=%s", mon, mon->fd, nicstr);
if (mon->json)
ret = qemuMonitorJSONAddPCINetwork(mon, nicstr, guestDomain,
guestBus, guestSlot);
ret = qemuMonitorJSONAddPCINetwork(mon, nicstr, guestAddr);
else
ret = qemuMonitorTextAddPCINetwork(mon, nicstr, guestDomain,
guestBus, guestSlot);
ret = qemuMonitorTextAddPCINetwork(mon, nicstr, guestAddr);
return ret;
}
int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
unsigned guestDomain,
unsigned guestBus,
unsigned guestSlot)
virDomainDevicePCIAddress *guestAddr)
{
int ret;
DEBUG("mon=%p, fd=%d domain=%d bus=%d slot=%d",
mon, mon->fd, guestDomain, guestBus, guestSlot);
DEBUG("mon=%p, fd=%d domain=%d bus=%d slot=%d function=%d",
mon, mon->fd, guestAddr->domain, guestAddr->bus,
guestAddr->slot, guestAddr->function);
if (mon->json)
ret = qemuMonitorJSONRemovePCIDevice(mon, guestDomain,
guestBus, guestSlot);
ret = qemuMonitorJSONRemovePCIDevice(mon, guestAddr);
else
ret = qemuMonitorTextRemovePCIDevice(mon, guestDomain,
guestBus, guestSlot);
ret = qemuMonitorTextRemovePCIDevice(mon, guestAddr);
return ret;
}
......
......@@ -222,13 +222,8 @@ int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon,
int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
unsigned hostDomain,
unsigned hostBus,
unsigned hostSlot,
unsigned hostFunction,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *hostAddr,
virDomainDevicePCIAddress *guestAddr);
/* XXX disk driver type eg, qcow/etc.
* XXX cache mode
......@@ -236,23 +231,17 @@ int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
const char *path,
const char *bus,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *guestAddr);
/* XXX do we really want to hardcode 'nicstr' as the
* sendable item here
*/
int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
const char *nicstr,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
unsigned guestDomain,
unsigned guestBus,
unsigned guestSlot);
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
......
......@@ -1206,9 +1206,7 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon,
/* XXX qemu also returns a 'function' number now */
static int
qemuMonitorJSONGetGuestAddress(virJSONValuePtr reply,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot)
virDomainDevicePCIAddress *guestAddr)
{
virJSONValuePtr addr;
......@@ -1219,47 +1217,48 @@ qemuMonitorJSONGetGuestAddress(virJSONValuePtr reply,
return -1;
}
if (virJSONValueObjectGetNumberUint(addr, "domain", guestDomain) < 0) {
if (virJSONValueObjectGetNumberUint(addr, "domain", &guestAddr->domain) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device domain number"));
return -1;
}
if (virJSONValueObjectGetNumberUint(addr, "bus", guestBus) < 0) {
if (virJSONValueObjectGetNumberUint(addr, "bus", &guestAddr->bus) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device bus number"));
return -1;
}
if (virJSONValueObjectGetNumberUint(addr, "slot", guestSlot) < 0) {
if (virJSONValueObjectGetNumberUint(addr, "slot", &guestAddr->slot) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device slot number"));
return -1;
}
if (virJSONValueObjectGetNumberUint(addr, "function", &guestAddr->function) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("pci_add reply was missing device function number"));
return -1;
}
return 0;
}
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
unsigned hostDomain ATTRIBUTE_UNUSED,
unsigned hostBus,
unsigned hostSlot,
unsigned hostFunction,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot)
virDomainDevicePCIAddress *hostAddr,
virDomainDevicePCIAddress *guestAddr)
{
int ret;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
char *dev;
*guestDomain = *guestBus = *guestSlot = 0;
memset(guestAddr, 0, sizeof(*guestAddr));
/* XXX hostDomain */
if (virAsprintf(&dev, "host=%.2x:%.2x.%.1x",
hostBus, hostSlot, hostFunction) < 0) {
hostAddr->bus, hostAddr->slot, hostAddr->function) < 0) {
virReportOOMError(NULL);
return -1;
}
......@@ -1279,7 +1278,7 @@ int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
if (ret == 0 &&
qemuMonitorJSONGetGuestAddress(reply, guestDomain, guestBus, guestSlot) < 0)
qemuMonitorJSONGetGuestAddress(reply, guestAddr) < 0)
ret = -1;
virJSONValueFree(cmd);
......@@ -1291,15 +1290,14 @@ int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
const char *path,
const char *bus,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot) {
virDomainDevicePCIAddress *guestAddr)
{
int ret;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
char *dev;
*guestDomain = *guestBus = *guestSlot = 0;
memset(guestAddr, 0, sizeof(*guestAddr));
if (virAsprintf(&dev, "file=%s,if=%s", path, bus) < 0) {
virReportOOMError(NULL);
......@@ -1321,7 +1319,7 @@ int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
if (ret == 0 &&
qemuMonitorJSONGetGuestAddress(reply, guestDomain, guestBus, guestSlot) < 0)
qemuMonitorJSONGetGuestAddress(reply, guestAddr) < 0)
ret = -1;
virJSONValueFree(cmd);
......@@ -1332,9 +1330,7 @@ int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
const char *nicstr,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot)
virDomainDevicePCIAddress *guestAddr)
{
int ret;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("pci_add",
......@@ -1344,7 +1340,7 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
NULL);
virJSONValuePtr reply = NULL;
*guestDomain = *guestBus = *guestSlot = 0;
memset(guestAddr, 0, sizeof(*guestAddr));
if (!cmd)
return -1;
......@@ -1355,7 +1351,7 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
if (ret == 0 &&
qemuMonitorJSONGetGuestAddress(reply, guestDomain, guestBus, guestSlot) < 0)
qemuMonitorJSONGetGuestAddress(reply, guestAddr) < 0)
ret = -1;
virJSONValueFree(cmd);
......@@ -1365,17 +1361,16 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
unsigned guestDomain,
unsigned guestBus,
unsigned guestSlot)
virDomainDevicePCIAddress *guestAddr)
{
int ret;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
char *addr;
/* XXX what about function ? */
if (virAsprintf(&addr, "%.4x:%.2x:%.2x",
guestDomain, guestBus, guestSlot) < 0) {
guestAddr->domain, guestAddr->bus, guestAddr->slot) < 0) {
virReportOOMError(NULL);
return -1;
}
......
......@@ -112,32 +112,20 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon,
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
unsigned hostDomain,
unsigned hostBus,
unsigned hostSlot,
unsigned hostFunction,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *hostAddr,
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
const char *path,
const char *bus,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
const char *nicstr,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
unsigned guestDomain,
unsigned guestBus,
unsigned guestSlot);
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorJSONSendFileHandle(qemuMonitorPtr mon,
const char *fdname,
......
......@@ -1281,9 +1281,7 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon,
static int
qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
const char *reply,
unsigned *domain,
unsigned *bus,
unsigned *slot)
virDomainDevicePCIAddress *addr)
{
char *s, *e;
......@@ -1300,7 +1298,7 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
if (STRPREFIX(s, "domain ")) {
s += strlen("domain ");
if (virStrToLong_ui(s, &e, 10, domain) == -1) {
if (virStrToLong_ui(s, &e, 10, &addr->domain) == -1) {
VIR_WARN(_("Unable to parse domain number '%s'\n"), s);
return -1;
}
......@@ -1318,7 +1316,7 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
}
s += strlen("bus ");
if (virStrToLong_ui(s, &e, 10, bus) == -1) {
if (virStrToLong_ui(s, &e, 10, &addr->bus) == -1) {
VIR_WARN(_("Unable to parse bus number '%s'\n"), s);
return -1;
}
......@@ -1335,7 +1333,7 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
}
s += strlen("slot ");
if (virStrToLong_ui(s, &e, 10, slot) == -1) {
if (virStrToLong_ui(s, &e, 10, &addr->slot) == -1) {
VIR_WARN(_("Unable to parse slot number '%s'\n"), s);
return -1;
}
......@@ -1345,23 +1343,18 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
unsigned hostDomain ATTRIBUTE_UNUSED,
unsigned hostBus,
unsigned hostSlot,
unsigned hostFunction,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot)
virDomainDevicePCIAddress *hostAddr,
virDomainDevicePCIAddress *guestAddr)
{
char *cmd;
char *reply = NULL;
int ret = -1;
*guestDomain = *guestBus = *guestSlot = 0;
memset(guestAddr, 0, sizeof(*guestAddr));
/* XXX hostDomain */
/* XXX hostAddr->domain */
if (virAsprintf(&cmd, "pci_add pci_addr=auto host host=%.2x:%.2x.%.1x",
hostBus, hostSlot, hostFunction) < 0) {
hostAddr->bus, hostAddr->slot, hostAddr->function) < 0) {
virReportOOMError(NULL);
goto cleanup;
}
......@@ -1378,10 +1371,7 @@ int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
goto cleanup;
}
if (qemuMonitorTextParsePciAddReply(mon, reply,
guestDomain,
guestBus,
guestSlot) < 0) {
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
_("parsing pci_add reply failed: %s"), reply);
goto cleanup;
......@@ -1399,9 +1389,8 @@ cleanup:
int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
const char *path,
const char *bus,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot) {
virDomainDevicePCIAddress *guestAddr)
{
char *cmd = NULL;
char *reply = NULL;
char *safe_path = NULL;
......@@ -1427,8 +1416,7 @@ try_command:
goto cleanup;
}
if (qemuMonitorTextParsePciAddReply(mon, reply,
guestDomain, guestBus, guestSlot) < 0) {
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
VIR_FREE(reply);
VIR_FREE(cmd);
......@@ -1453,9 +1441,7 @@ cleanup:
int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
const char *nicstr,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot)
virDomainDevicePCIAddress *guestAddr)
{
char *cmd;
char *reply = NULL;
......@@ -1472,8 +1458,7 @@ int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
goto cleanup;
}
if (qemuMonitorTextParsePciAddReply(mon, reply,
guestDomain, guestBus, guestSlot) < 0) {
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
_("parsing pci_add reply failed: %s"), reply);
goto cleanup;
......@@ -1489,9 +1474,7 @@ cleanup:
int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
unsigned guestDomain,
unsigned guestBus,
unsigned guestSlot)
virDomainDevicePCIAddress *guestAddr)
{
char *cmd = NULL;
char *reply = NULL;
......@@ -1500,13 +1483,14 @@ int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
try_command:
if (tryOldSyntax) {
if (virAsprintf(&cmd, "pci_del 0 %.2x", guestSlot) < 0) {
if (virAsprintf(&cmd, "pci_del 0 %.2x", guestAddr->slot) < 0) {
virReportOOMError(NULL);
goto cleanup;
}
} else {
/* XXX function ? */
if (virAsprintf(&cmd, "pci_del pci_addr=%.4x:%.2x:%.2x",
guestDomain, guestBus, guestSlot) < 0) {
guestAddr->domain, guestAddr->bus, guestAddr->slot) < 0) {
virReportOOMError(NULL);
goto cleanup;
}
......@@ -1534,7 +1518,7 @@ try_command:
strstr(reply, "Invalid pci address")) {
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
_("failed to detach PCI device, invalid address %.4x:%.2x:%.2x: %s"),
guestDomain, guestBus, guestSlot, reply);
guestAddr->domain, guestAddr->bus, guestAddr->slot, reply);
goto cleanup;
}
......
......@@ -116,32 +116,20 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon,
int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
unsigned hostDomain,
unsigned hostBus,
unsigned hostSlot,
unsigned hostFunction,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *hostAddr,
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
const char *path,
const char *bus,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
const char *nicstr,
unsigned *guestDomain,
unsigned *guestBus,
unsigned *guestSlot);
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
unsigned guestDomain,
unsigned guestBus,
unsigned guestSlot);
virDomainDevicePCIAddress *guestAddr);
int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
const char *fdname,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册