This function is going to take on some of the functionality of its
subordinate functions, which all live in qemu_hotplug.c.
qemuDomainDetachDeviceControllerLive() is only called from
qemuDomainDetachDeviceLive() (and will soon be merged into
qemuDomainDetachControllerDevice(), which is in qemu_hotplug.c), so
it is also moved.
Signed-off-by: Laine Stump <laine(a)laine.org>
---
Change from V1: take out changes of functions from global to static, move them to a
separage patch (now in Patch 05/14)
src/qemu/qemu_driver.c | 95 ----------------------------------------
src/qemu/qemu_hotplug.c | 97 +++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_hotplug.h | 5 +++
3 files changed, 102 insertions(+), 95 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b27c6ce98e..6f5a4224c5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8001,101 +8001,6 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
return ret;
}
-static int
-qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
- virDomainDeviceDefPtr dev,
- bool async)
-{
- virDomainControllerDefPtr cont = dev->data.controller;
- int ret = -1;
-
- switch (cont->type) {
- case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
- ret = qemuDomainDetachControllerDevice(driver, vm, dev, async);
- break;
- default :
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
- _("'%s' controller cannot be hot unplugged."),
- virDomainControllerTypeToString(cont->type));
- }
- return ret;
-}
-
-static int
-qemuDomainDetachDeviceLive(virDomainObjPtr vm,
- virDomainDeviceDefPtr dev,
- virQEMUDriverPtr driver,
- bool async)
-{
- int ret = -1;
-
- switch ((virDomainDeviceType)dev->type) {
- case VIR_DOMAIN_DEVICE_DISK:
- ret = qemuDomainDetachDeviceDiskLive(driver, vm, dev, async);
- break;
- case VIR_DOMAIN_DEVICE_CONTROLLER:
- ret = qemuDomainDetachDeviceControllerLive(driver, vm, dev, async);
- break;
- case VIR_DOMAIN_DEVICE_LEASE:
- ret = qemuDomainDetachLease(driver, vm, dev->data.lease);
- break;
- case VIR_DOMAIN_DEVICE_NET:
- ret = qemuDomainDetachNetDevice(driver, vm, dev, async);
- break;
- case VIR_DOMAIN_DEVICE_HOSTDEV:
- ret = qemuDomainDetachHostDevice(driver, vm, dev, async);
- break;
- case VIR_DOMAIN_DEVICE_CHR:
- ret = qemuDomainDetachChrDevice(driver, vm, dev->data.chr, async);
- break;
- case VIR_DOMAIN_DEVICE_RNG:
- ret = qemuDomainDetachRNGDevice(driver, vm, dev->data.rng, async);
- break;
- case VIR_DOMAIN_DEVICE_MEMORY:
- ret = qemuDomainDetachMemoryDevice(driver, vm, dev->data.memory, async);
- break;
- case VIR_DOMAIN_DEVICE_SHMEM:
- ret = qemuDomainDetachShmemDevice(driver, vm, dev->data.shmem, async);
- break;
- case VIR_DOMAIN_DEVICE_WATCHDOG:
- ret = qemuDomainDetachWatchdog(driver, vm, dev->data.watchdog, async);
- break;
- case VIR_DOMAIN_DEVICE_INPUT:
- ret = qemuDomainDetachInputDevice(vm, dev->data.input, async);
- break;
- case VIR_DOMAIN_DEVICE_REDIRDEV:
- ret = qemuDomainDetachRedirdevDevice(driver, vm, dev->data.redirdev, async);
- break;
-
- case VIR_DOMAIN_DEVICE_VSOCK:
- ret = qemuDomainDetachVsockDevice(vm, dev->data.vsock, async);
- break;
-
- case VIR_DOMAIN_DEVICE_FS:
- case VIR_DOMAIN_DEVICE_SOUND:
- case VIR_DOMAIN_DEVICE_VIDEO:
- case VIR_DOMAIN_DEVICE_GRAPHICS:
- case VIR_DOMAIN_DEVICE_HUB:
- case VIR_DOMAIN_DEVICE_SMARTCARD:
- case VIR_DOMAIN_DEVICE_MEMBALLOON:
- case VIR_DOMAIN_DEVICE_NVRAM:
- case VIR_DOMAIN_DEVICE_NONE:
- case VIR_DOMAIN_DEVICE_TPM:
- case VIR_DOMAIN_DEVICE_PANIC:
- case VIR_DOMAIN_DEVICE_IOMMU:
- case VIR_DOMAIN_DEVICE_LAST:
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
- _("live detach of device '%s' is not
supported"),
- virDomainDeviceTypeToString(dev->type));
- break;
- }
-
- if (ret == 0)
- ret = qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE);
-
- return ret;
-}
static int
qemuDomainChangeDiskLive(virDomainObjPtr vm,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index c1d2d00016..7be0f341b7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -6190,6 +6190,103 @@ qemuDomainDetachLease(virQEMUDriverPtr driver,
}
+static int
+qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev,
+ bool async)
+{
+ virDomainControllerDefPtr cont = dev->data.controller;
+ int ret = -1;
+
+ switch (cont->type) {
+ case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
+ ret = qemuDomainDetachControllerDevice(driver, vm, dev, async);
+ break;
+ default :
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+ _("'%s' controller cannot be hot unplugged."),
+ virDomainControllerTypeToString(cont->type));
+ }
+ return ret;
+}
+
+int
+qemuDomainDetachDeviceLive(virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev,
+ virQEMUDriverPtr driver,
+ bool async)
+{
+ int ret = -1;
+
+ switch ((virDomainDeviceType)dev->type) {
+ case VIR_DOMAIN_DEVICE_DISK:
+ ret = qemuDomainDetachDeviceDiskLive(driver, vm, dev, async);
+ break;
+ case VIR_DOMAIN_DEVICE_CONTROLLER:
+ ret = qemuDomainDetachDeviceControllerLive(driver, vm, dev, async);
+ break;
+ case VIR_DOMAIN_DEVICE_LEASE:
+ ret = qemuDomainDetachLease(driver, vm, dev->data.lease);
+ break;
+ case VIR_DOMAIN_DEVICE_NET:
+ ret = qemuDomainDetachNetDevice(driver, vm, dev, async);
+ break;
+ case VIR_DOMAIN_DEVICE_HOSTDEV:
+ ret = qemuDomainDetachHostDevice(driver, vm, dev, async);
+ break;
+ case VIR_DOMAIN_DEVICE_CHR:
+ ret = qemuDomainDetachChrDevice(driver, vm, dev->data.chr, async);
+ break;
+ case VIR_DOMAIN_DEVICE_RNG:
+ ret = qemuDomainDetachRNGDevice(driver, vm, dev->data.rng, async);
+ break;
+ case VIR_DOMAIN_DEVICE_MEMORY:
+ ret = qemuDomainDetachMemoryDevice(driver, vm, dev->data.memory, async);
+ break;
+ case VIR_DOMAIN_DEVICE_SHMEM:
+ ret = qemuDomainDetachShmemDevice(driver, vm, dev->data.shmem, async);
+ break;
+ case VIR_DOMAIN_DEVICE_WATCHDOG:
+ ret = qemuDomainDetachWatchdog(driver, vm, dev->data.watchdog, async);
+ break;
+ case VIR_DOMAIN_DEVICE_INPUT:
+ ret = qemuDomainDetachInputDevice(vm, dev->data.input, async);
+ break;
+ case VIR_DOMAIN_DEVICE_REDIRDEV:
+ ret = qemuDomainDetachRedirdevDevice(driver, vm, dev->data.redirdev, async);
+ break;
+
+ case VIR_DOMAIN_DEVICE_VSOCK:
+ ret = qemuDomainDetachVsockDevice(vm, dev->data.vsock, async);
+ break;
+
+ case VIR_DOMAIN_DEVICE_FS:
+ case VIR_DOMAIN_DEVICE_SOUND:
+ case VIR_DOMAIN_DEVICE_VIDEO:
+ case VIR_DOMAIN_DEVICE_GRAPHICS:
+ case VIR_DOMAIN_DEVICE_HUB:
+ case VIR_DOMAIN_DEVICE_SMARTCARD:
+ case VIR_DOMAIN_DEVICE_MEMBALLOON:
+ case VIR_DOMAIN_DEVICE_NVRAM:
+ case VIR_DOMAIN_DEVICE_NONE:
+ case VIR_DOMAIN_DEVICE_TPM:
+ case VIR_DOMAIN_DEVICE_PANIC:
+ case VIR_DOMAIN_DEVICE_IOMMU:
+ case VIR_DOMAIN_DEVICE_LAST:
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+ _("live detach of device '%s' is not
supported"),
+ virDomainDeviceTypeToString(dev->type));
+ break;
+ }
+
+ if (ret == 0)
+ ret = qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE);
+
+ return ret;
+}
+
+
static int
qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
virDomainObjPtr vm,
diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
index 7ac03b7810..10593cf83c 100644
--- a/src/qemu/qemu_hotplug.h
+++ b/src/qemu/qemu_hotplug.h
@@ -158,6 +158,11 @@ int qemuDomainDetachRNGDevice(virQEMUDriverPtr driver,
virDomainRNGDefPtr rng,
bool async);
+int qemuDomainDetachDeviceLive(virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev,
+ virQEMUDriverPtr driver,
+ bool async);
+
void qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *alias);
--
2.20.1