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

Ján Tomko jtomko at redhat.com
Tue Mar 12 13:00:55 UTC 2019


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 at redhat.com>
>---
> 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);
> }
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190312/2bf6f18d/attachment-0001.sig>


More information about the libvir-list mailing list