[PATCH 28/35] qemuDomainAttachDiskGeneric: Split up frontend and backend attachment

Peter Krempa pkrempa at redhat.com
Fri May 21 12:47:28 UTC 2021


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 <pkrempa at redhat.com>
---
 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 3772c5b4b8..e13a739ade 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.31.1




More information about the libvir-list mailing list