[libvirt RFC 09/24] qemu_snapshot: refactor qemuSnapshotDelete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move code around to make it clear what is called when deleting single
snapshot or children snapshots.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/qemu/qemu_snapshot.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 6033deafed..c1c67ac445 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2350,25 +2350,28 @@ qemuSnapshotDelete(virDomainObj *vm,
                 }
             }
         }
-    } else if (snap->nchildren) {
-        rep.dir = cfg->snapshotDir;
-        rep.parent = snap->parent;
-        rep.vm = vm;
-        rep.err = 0;
-        rep.xmlopt = driver->xmlopt;
-        rep.writeMetadata = qemuDomainSnapshotWriteMetadata;
-        virDomainMomentForEachChild(snap,
-                                    qemuSnapshotChildrenReparent,
-                                    &rep);
-        if (rep.err < 0)
-            goto endjob;
-        virDomainMomentMoveChildren(snap, snap->parent);
-    }
 
-    if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
-        virDomainMomentDropChildren(snap);
-        ret = 0;
+        if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
+            virDomainMomentDropChildren(snap);
+            ret = 0;
+        } else {
+            ret = qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only);
+        }
     } else {
+        if (snap->nchildren) {
+            rep.dir = cfg->snapshotDir;
+            rep.parent = snap->parent;
+            rep.vm = vm;
+            rep.err = 0;
+            rep.xmlopt = driver->xmlopt;
+            rep.writeMetadata = qemuDomainSnapshotWriteMetadata;
+            virDomainMomentForEachChild(snap,
+                                        qemuSnapshotChildrenReparent,
+                                        &rep);
+            if (rep.err < 0)
+                goto endjob;
+            virDomainMomentMoveChildren(snap, snap->parent);
+        }
         ret = qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only);
     }
 
-- 
2.37.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux