The pci_del command is not being ported to QMP. Convert all the
QEMU hotplug code over to use device_del whenever it is available
to avoid the pci_del problem
* src/qemu/qemu_driver.c: Convert unplug code to device_del
---
src/qemu/qemu_driver.c | 60 +++++++++++++++++++++++++++++++++--------------
1 files changed, 42 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4dd5843..c811fba 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6312,7 +6312,8 @@ static int qemudDomainAttachDeviceFlags(virDomainPtr dom,
static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver,
virDomainObjPtr vm,
- virDomainDeviceDefPtr dev)
+ virDomainDeviceDefPtr dev,
+ unsigned long long qemuCmdFlags)
{
int i, ret = -1;
virDomainDiskDefPtr detach = NULL;
@@ -6339,10 +6340,17 @@ static int qemudDomainDetachPciDiskDevice(struct qemud_driver
*driver,
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorRemovePCIDevice(priv->mon,
- &detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitor(vm);
- goto cleanup;
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+ if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
+ qemuDomainObjExitMonitor(vm);
+ goto cleanup;
+ }
+ } else {
+ if (qemuMonitorRemovePCIDevice(priv->mon,
+ &detach->info.addr.pci) < 0) {
+ qemuDomainObjExitMonitor(vm);
+ goto cleanup;
+ }
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -6453,7 +6461,8 @@ cleanup:
static int
qemudDomainDetachNetDevice(struct qemud_driver *driver,
virDomainObjPtr vm,
- virDomainDeviceDefPtr dev)
+ virDomainDeviceDefPtr dev,
+ unsigned long long qemuCmdFlags)
{
int i, ret = -1;
virDomainNetDefPtr detach = NULL;
@@ -6498,10 +6507,17 @@ qemudDomainDetachNetDevice(struct qemud_driver *driver,
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorRemovePCIDevice(priv->mon,
- &detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cleanup;
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+ if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
+ qemuDomainObjExitMonitor(vm);
+ goto cleanup;
+ }
+ } else {
+ if (qemuMonitorRemovePCIDevice(priv->mon,
+ &detach->info.addr.pci) < 0) {
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ goto cleanup;
+ }
}
if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
@@ -6551,7 +6567,8 @@ cleanup:
static int qemudDomainDetachHostPciDevice(struct qemud_driver *driver,
virDomainObjPtr vm,
- virDomainDeviceDefPtr dev)
+ virDomainDeviceDefPtr dev,
+ unsigned long long qemuCmdFlags)
{
virDomainHostdevDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -6595,10 +6612,17 @@ static int qemudDomainDetachHostPciDevice(struct qemud_driver
*driver,
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorRemovePCIDevice(priv->mon,
- &detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- return -1;
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+ if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
+ qemuDomainObjExitMonitor(vm);
+ return -1;
+ }
+ } else {
+ if (qemuMonitorRemovePCIDevice(priv->mon,
+ &detach->info.addr.pci) < 0) {
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ return -1;
+ }
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -6725,7 +6749,7 @@ static int qemudDomainDetachHostDevice(struct qemud_driver *driver,
switch (hostdev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
- ret = qemudDomainDetachHostPciDevice(driver, vm, dev);
+ ret = qemudDomainDetachHostPciDevice(driver, vm, dev, qemuCmdFlags);
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
ret = qemudDomainDetachHostUsbDevice(driver, vm, dev, qemuCmdFlags);
@@ -6785,9 +6809,9 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) {
- ret = qemudDomainDetachPciDiskDevice(driver, vm, dev);
+ ret = qemudDomainDetachPciDiskDevice(driver, vm, dev, qemuCmdFlags);
} else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
- ret = qemudDomainDetachNetDevice(driver, vm, dev);
+ ret = qemudDomainDetachNetDevice(driver, vm, dev, qemuCmdFlags);
} else if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) {
if (dev->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
ret = qemudDomainDetachPciControllerDevice(driver, vm, dev,
--
1.6.5.2