]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_snapshot: check only once if snapshot is external
authorPavel Hrdina <phrdina@redhat.com>
Mon, 6 Mar 2023 11:21:16 +0000 (12:21 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 22 Aug 2023 14:06:40 +0000 (16:06 +0200)
There will be more external snapshot checks introduced by following
patch so group them together.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_snapshot.c

index 8d0581d33b3ae70671f300169f2736751b904091..dca95b415b70c5624bcf4eb7a2a970f7e15b6637 100644 (file)
@@ -3728,18 +3728,18 @@ qemuSnapshotDeleteValidate(virDomainObj *vm,
         }
     }
 
-    if (virDomainSnapshotIsExternal(snap) &&
-        qemuDomainHasBlockjob(vm, false)) {
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
-                       _("cannot delete external snapshots when there is another active block job"));
-        return -1;
-    }
+    if (virDomainSnapshotIsExternal(snap)) {
+        if (qemuDomainHasBlockjob(vm, false)) {
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                           _("cannot delete external snapshots when there is another active block job"));
+            return -1;
+        }
 
-    if (virDomainSnapshotIsExternal(snap) &&
-        (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("deletion of external disk snapshots with children not supported"));
-        return -1;
+        if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("deletion of external disk snapshots with children not supported"));
+            return -1;
+        }
     }
 
     return 0;