]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: snapshot: Initialize data for inactive config of snapshot earlier
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Jul 2019 16:40:25 +0000 (18:40 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 25 Jul 2019 11:21:32 +0000 (13:21 +0200)
qemuDomainSnapshotDiskDataCollect copies the source of the disk from the
live config into the inactive config. Move this operation earlier so
that if we initialize it for use for the particular instance the
run-time-only data is not copied.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index 889c0b85e6738674d700d661e28f544e7f22790d..e7720fbd998db2418e8474985cbdc2376e3bc270 100644 (file)
@@ -15114,6 +15114,22 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver,
         if (virStorageSourceInitChainElement(dd->src, dd->disk->src, false) < 0)
             goto cleanup;
 
+        /* Note that it's unsafe to assume that the disks in the persistent
+         * definition match up with the disks in the live definition just by
+         * checking that the target name is the same. We've done that
+         * historically this way though. */
+        if (vm->newDef &&
+            (dd->persistdisk = virDomainDiskByName(vm->newDef, dd->disk->dst,
+                                                   false))) {
+
+            if (!(dd->persistsrc = virStorageSourceCopy(dd->src, false)))
+                goto cleanup;
+
+            if (virStorageSourceInitChainElement(dd->persistsrc,
+                                                 dd->persistdisk->src, false) < 0)
+                goto cleanup;
+        }
+
         if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0)
             goto cleanup;
 
@@ -15131,22 +15147,6 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver,
                     VIR_FREE(backingStoreStr);
             }
         }
-
-        /* Note that it's unsafe to assume that the disks in the persistent
-         * definition match up with the disks in the live definition just by
-         * checking that the target name is the same. We've done that
-         * historically this way though. */
-        if (vm->newDef &&
-            (dd->persistdisk = virDomainDiskByName(vm->newDef, dd->disk->dst,
-                                                   false))) {
-
-            if (!(dd->persistsrc = virStorageSourceCopy(dd->src, false)))
-                goto cleanup;
-
-            if (virStorageSourceInitChainElement(dd->persistsrc,
-                                                 dd->persistdisk->src, false) < 0)
-                goto cleanup;
-        }
     }
 
     VIR_STEAL_PTR(*rdata, data);