]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainAttachDiskGeneric: Split up frontend and backend attachment
authorPeter Krempa <pkrempa@redhat.com>
Fri, 21 May 2021 08:34:55 +0000 (10:34 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 24 May 2021 18:38:08 +0000 (20:38 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_hotplug.c

index 0fe6893c873996a3302ea89f9cb08701ad7c8d15..d1908fbce61d8363f438bb723511df5eb875eeca 100644 (file)
@@ -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)