Fill in the required fields in qemuBlockStorageSourceChainData to handle
the hotplug so that we can simplify the cleanup code.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index ee72762d0d..31dc9a43b2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -700,9 +700,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
qemuDomainObjPrivate *priv = vm->privateData;
g_autofree char *devstr = NULL;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
- g_autoptr(virJSONValue) corProps = NULL;
- g_autofree char *corAlias = NULL;
- bool corAdded = false;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
@@ -718,16 +715,17 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk)))
goto cleanup;
} else if (blockdev) {
+ if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src,
+
priv->qemuCaps)))
+ goto cleanup;
+
if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) {
- if (!(corProps = qemuBlockStorageGetCopyOnReadProps(disk)))
+ if (!(data->copyOnReadProps = qemuBlockStorageGetCopyOnReadProps(disk)))
goto cleanup;
- corAlias = g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopyOnRead);
+ data->copyOnReadNodename =
g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopyOnRead);
}
- if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src,
-
priv->qemuCaps)))
- goto cleanup;
} else {
if (!(data = qemuBuildStorageSourceChainAttachPrepareDrive(disk,
priv->qemuCaps)))
@@ -746,13 +744,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0)
goto exit_monitor;
- if (corProps) {
- if (qemuMonitorBlockdevAdd(priv->mon, &corProps) < 0)
- goto exit_monitor;
-
- corAdded = true;
- }
-
if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info) < 0)
goto exit_monitor;
@@ -793,8 +784,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
return ret;
exit_monitor:
- if (corAdded)
- ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias));
qemuBlockStorageSourceChainDetach(priv->mon, data);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
--
2.31.1