]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_snapshot: fix external snapshot deletion for non-active snapshots
authorPavel Hrdina <phrdina@redhat.com>
Thu, 2 Mar 2023 22:48:08 +0000 (23:48 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Thu, 9 Mar 2023 16:16:11 +0000 (17:16 +0100)
For shutoff VMs we don't have the storage source backing chain
populated so it will fail this check and error out. Move it to
part that is done only when VM is running.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_snapshot.c

index 7207b5879af59cf51279a14113df4d615f77817f..7aa4195f04d0a152656141fe40647a90b38dec05 100644 (file)
@@ -2331,18 +2331,6 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm,
         if (!data->domDisk)
             return -1;
 
-        data->diskSrc = virStorageSourceChainLookupBySource(data->domDisk->src,
-                                                            data->snapDisk->src,
-                                                            &data->prevDiskSrc);
-        if (!data->diskSrc)
-            return -1;
-
-        if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapDisk->src)) {
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-                           _("VM disk source and snapshot disk source are not the same"));
-            return -1;
-        }
-
         data->parentDomDisk = virDomainDiskByTarget(snapdef->parent.dom,
                                                     data->snapDisk->name);
         if (!data->parentDomDisk) {
@@ -2353,6 +2341,18 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm,
         }
 
         if (virDomainObjIsActive(vm)) {
+            data->diskSrc = virStorageSourceChainLookupBySource(data->domDisk->src,
+                                                                data->snapDisk->src,
+                                                                &data->prevDiskSrc);
+            if (!data->diskSrc)
+                return -1;
+
+            if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapDisk->src)) {
+                virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                               _("VM disk source and snapshot disk source are not the same"));
+                return -1;
+            }
+
             data->parentDiskSrc = data->diskSrc->backingStore;
             if (!virStorageSourceIsBacking(data->parentDiskSrc)) {
                 virReportError(VIR_ERR_OPERATION_FAILED, "%s",