From 4f79d7ada690a14ff71a7600f389295ccd47b17d Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 21 May 2021 10:34:55 +0200 Subject: [PATCH] qemuDomainAttachDiskGeneric: Split up frontend and backend attachment MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Split up the monitor contexts to attach the backend of the disk and the frontend device in preparation for hotplugging transient disks where we'll need to add the code for adding the transient overlay between these two steps. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko Reviewed-by: Pavel Hrdina --- src/qemu/qemu_hotplug.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0fe6893c87..d1908fbce6 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -723,15 +723,22 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, return -1; } - if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps))) - return -1; - qemuDomainObjEnterMonitor(driver, vm); rc = qemuBlockStorageSourceChainAttach(priv->mon, data); - if (rc == 0 && - (rc = qemuDomainAttachExtensionDevice(priv->mon, &disk->info)) == 0) + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -2; + + if (rc < 0) + goto rollback; + + if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps))) + goto rollback; + + qemuDomainObjEnterMonitor(driver, vm); + + if ((rc = qemuDomainAttachExtensionDevice(priv->mon, &disk->info)) == 0) extensionDeviceAttached = true; if (rc == 0) -- 2.47.2