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

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

 



On Mon, Mar 11, 2019 at 09:38:33PM -0500, Eric Blake wrote:
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,

Rather than introducing a bool parameter (which shows up as
non-descriptive 'false' in the caller), I'd put it into the name of the
function:

virDomainSnapshotForEachTopological

which would be a thin wrapper for virDomainSnapshotForEachDescendant.
Alternatively, the one caller can call virDomainSnapshotForEachDescendant
with &snapshots->metaroot directly.

Jano

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

Attachment: signature.asc
Description: PGP signature

--
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