From: Peter Krempa Date: Fri, 21 May 2021 08:34:55 +0000 (+0200) Subject: qemuDomainAttachDiskGeneric: Split up frontend and backend attachment X-Git-Tag: v7.4.0-rc1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f79d7ada690a14ff71a7600f389295ccd47b17d;p=thirdparty%2Flibvirt.git qemuDomainAttachDiskGeneric: Split up frontend and backend attachment 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 --- 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)