|
|
0a7476 |
From ff7bc70a5e5d7aaf354ce501653beb82429030fe Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <ff7bc70a5e5d7aaf354ce501653beb82429030fe@dist-git>
|
|
|
0a7476 |
From: Laine Stump <laine@laine.org>
|
|
|
0a7476 |
Date: Thu, 11 Apr 2019 15:14:46 -0400
|
|
|
0a7476 |
Subject: [PATCH] qemu_hotplug: separate Chr|Lease from other devices in
|
|
|
0a7476 |
DetachDevice switch
|
|
|
0a7476 |
|
|
|
0a7476 |
The Chr and Lease devices have detach code that is too different from
|
|
|
0a7476 |
the other device types to handle with common functionality (which will
|
|
|
0a7476 |
soon be added at the end of qemuDomainDetachDeviceLive(). In order to
|
|
|
0a7476 |
make this difference obvious, move the cases for those two device
|
|
|
0a7476 |
types to the top of the switch statement in
|
|
|
0a7476 |
qemuDomainDetachDeviceLive(), have the cases return immediately so the
|
|
|
0a7476 |
future common code at the end of the function will be skipped, and
|
|
|
0a7476 |
also include some hopefully helpful comments to remind future
|
|
|
0a7476 |
maintainers why these two device types are treated differently.
|
|
|
0a7476 |
|
|
|
0a7476 |
Any attempt to detach an unsupported device type should also skip the
|
|
|
0a7476 |
future common code at the end of the function, so the case for
|
|
|
0a7476 |
unsupported types is similarly changed from a simple break to a return
|
|
|
0a7476 |
-1.
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Laine Stump <laine@laine.org>
|
|
|
0a7476 |
ACKed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit 2ec6faea798b2a7d8986b7a958e781b54d8a8070)
|
|
|
0a7476 |
|
|
|
0a7476 |
Partially-Resolves: https://bugzilla.redhat.com/1658198
|
|
|
0a7476 |
Signed-off-by: Laine Stump <laine@redhat.com>
|
|
|
0a7476 |
Signed-off-by: Laine Stump <laine@laine.org>
|
|
|
0a7476 |
Message-Id: <20190411191453.24055-35-laine@redhat.com>
|
|
|
0a7476 |
Acked-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
src/qemu/qemu_hotplug.c | 26 +++++++++++++++++++-------
|
|
|
0a7476 |
1 file changed, 19 insertions(+), 7 deletions(-)
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
index a655fc391f..9c0ee1c6a5 100644
|
|
|
0a7476 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
@@ -5657,24 +5657,36 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
|
|
|
0a7476 |
int ret = -1;
|
|
|
0a7476 |
|
|
|
0a7476 |
switch ((virDomainDeviceType)match->type) {
|
|
|
0a7476 |
+ /*
|
|
|
0a7476 |
+ * lease and chr devices don't follow the standard pattern of
|
|
|
0a7476 |
+ * the others, so they must have their own self-contained
|
|
|
0a7476 |
+ * Detach functions.
|
|
|
0a7476 |
+ */
|
|
|
0a7476 |
+ case VIR_DOMAIN_DEVICE_LEASE:
|
|
|
0a7476 |
+ return qemuDomainDetachLease(driver, vm, match->data.lease);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ case VIR_DOMAIN_DEVICE_CHR:
|
|
|
0a7476 |
+ return qemuDomainDetachChrDevice(driver, vm, match->data.chr, async);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ /*
|
|
|
0a7476 |
+ * All the other device types follow a very similar pattern -
|
|
|
0a7476 |
+ * First we call type-specific functions to 1) locate the
|
|
|
0a7476 |
+ * device we want to detach (based on the prototype device in
|
|
|
0a7476 |
+ * match) and 2) do any device-type-specific validation to
|
|
|
0a7476 |
+ * assure it is okay to detach the device.
|
|
|
0a7476 |
+ */
|
|
|
0a7476 |
case VIR_DOMAIN_DEVICE_DISK:
|
|
|
0a7476 |
ret = qemuDomainDetachDeviceDiskLive(driver, vm, match, async);
|
|
|
0a7476 |
break;
|
|
|
0a7476 |
case VIR_DOMAIN_DEVICE_CONTROLLER:
|
|
|
0a7476 |
ret = qemuDomainDetachControllerDevice(driver, vm, match, async);
|
|
|
0a7476 |
break;
|
|
|
0a7476 |
- case VIR_DOMAIN_DEVICE_LEASE:
|
|
|
0a7476 |
- ret = qemuDomainDetachLease(driver, vm, match->data.lease);
|
|
|
0a7476 |
- break;
|
|
|
0a7476 |
case VIR_DOMAIN_DEVICE_NET:
|
|
|
0a7476 |
ret = qemuDomainDetachNetDevice(driver, vm, match, async);
|
|
|
0a7476 |
break;
|
|
|
0a7476 |
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
|
|
0a7476 |
ret = qemuDomainDetachHostDevice(driver, vm, match, async);
|
|
|
0a7476 |
break;
|
|
|
0a7476 |
- case VIR_DOMAIN_DEVICE_CHR:
|
|
|
0a7476 |
- ret = qemuDomainDetachChrDevice(driver, vm, match->data.chr, async);
|
|
|
0a7476 |
- break;
|
|
|
0a7476 |
case VIR_DOMAIN_DEVICE_RNG:
|
|
|
0a7476 |
ret = qemuDomainDetachRNGDevice(driver, vm, match->data.rng, async);
|
|
|
0a7476 |
break;
|
|
|
0a7476 |
@@ -5714,7 +5726,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
|
|
|
0a7476 |
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
|
|
0a7476 |
_("live detach of device '%s' is not supported"),
|
|
|
0a7476 |
virDomainDeviceTypeToString(match->type));
|
|
|
0a7476 |
- break;
|
|
|
0a7476 |
+ return -1;
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
return ret;
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|