[PATCH v4 2/8] snapshot: Support topological virDomainSnapshotForEach()

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

 



Previous patches added topological sorting only for existing public
API functions, but it turns out that it will also useful for an
upcoming API addition that wants to visit all snapshots.  Add a
parameter, and update all existing callers (none of which care
about ordering).

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 src/conf/snapshot_conf.h | 1 +
 src/conf/snapshot_conf.c | 6 +++++-
 src/qemu/qemu_domain.c   | 2 +-
 src/vz/vz_driver.c       | 3 ++-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index 6d79dbb0da..ba9362c744 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -170,6 +170,7 @@ virDomainSnapshotObjPtr virDomainSnapshotFindByName(virDomainSnapshotObjListPtr
 void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
                                     virDomainSnapshotObjPtr snapshot);
 int virDomainSnapshotForEach(virDomainSnapshotObjListPtr snapshots,
+                             bool topological,
                              virHashIterator iter,
                              void *data);
 int virDomainSnapshotForEachChild(virDomainSnapshotObjPtr snapshot,
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index e2c91a5072..8235d7c526 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -1050,7 +1050,7 @@ virDomainSnapshotObjListFormat(virBufferPtr buf,
                               current_snapshot->def->name);
     virBufferAddLit(buf, ">\n");
     virBufferAdjustIndent(buf, 2);
-    if (virDomainSnapshotForEach(snapshots, virDomainSnapshotFormatOne,
+    if (virDomainSnapshotForEach(snapshots, false, virDomainSnapshotFormatOne,
                                  &data) < 0) {
         virBufferFreeAndReset(buf);
         return -1;
@@ -1293,9 +1293,13 @@ void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,

 int
 virDomainSnapshotForEach(virDomainSnapshotObjListPtr snapshots,
+                         bool topological,
                          virHashIterator iter,
                          void *data)
 {
+    if (topological)
+        return virDomainSnapshotForEachDescendant(&snapshots->metaroot,
+                                                  iter, data);
     return virHashForEach(snapshots->objs, iter, data);
 }

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1659e88478..34f3669967 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8675,7 +8675,7 @@ qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
     rem.vm = vm;
     rem.metadata_only = true;
     rem.err = 0;
-    virDomainSnapshotForEach(vm->snapshots, qemuDomainSnapshotDiscardAll,
+    virDomainSnapshotForEach(vm->snapshots, false, qemuDomainSnapshotDiscardAll,
                              &rem);
     if (rem.current)
         vm->current_snapshot = NULL;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 066d617524..2a0fc98f72 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2170,7 +2170,8 @@ vzFindCurrentSnapshot(virDomainSnapshotObjListPtr snapshots)
 {
     virDomainSnapshotObjPtr current = NULL;

-    virDomainSnapshotForEach(snapshots, vzCurrentSnapshotIterator, &current);
+    virDomainSnapshotForEach(snapshots, false, vzCurrentSnapshotIterator,
+                             &current);
     return current;
 }

-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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