[libvirt PATCH 18/20] qemu_snapshot: check only once if snapshot is external

Pavel Hrdina phrdina at redhat.com
Mon Mar 13 15:42:19 UTC 2023


There will be more external snapshot checks introduced by following
patch so group them together.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/qemu/qemu_snapshot.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 95297cfe6a..05386b11fe 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -3426,18 +3426,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;
-- 
2.39.2



More information about the libvir-list mailing list