]> git.ipfire.org Git - thirdparty/libvirt.git/commit
snapshots: Add flag to guarantee topological sort
authorEric Blake <eblake@redhat.com>
Fri, 8 Mar 2019 03:14:16 +0000 (21:14 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 13 Mar 2019 01:38:53 +0000 (20:38 -0500)
commitd16e5b15edbd226f6e1d7c2ce7ea8bf91c3b21c7
tree3f59a35a113b043055b32e372a9118751e080ba1
parent68ade25372bfe758d144e2e3d680fabc7f8a84f1
snapshots: Add flag to guarantee topological sort

When using virDomainSnapshotCreateXML with the REDEFINE flag on
multiple snapshot metadata XML descriptions, we require that a child
cannot be redefined before its parent.  Since libvirt already tracks a
DAG, it is more convenient if we can ensure that
virDomainListAllSnapshots() and friends have a way to return data in
an order that we can directly reuse, rather than having to
post-process the data ourselves to reconstruct the DAG.

Add VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL as our new guarantee (well, a
guarantee at the time of the API call conclusion; there's always a
possible TOCTTOU race where someone redefining snapshots in between
the API results and the client actually using the list might render
the list out-of-date). Four listing APIs are directly benefitted by
the new flag; additionally, since we document that the older racy
ListNames interfaces should be sized by using the same flags on their
Num counterparts, the Num interfaces must document when they accept
(and ignore) the flag.

We could have supported the new flag just for the ListAll APIs (to
discourage people from using the older racy Num/ListNames APIs), but
it feels weird to special-case this flag value as being applicable to
only a subset of the API while all other List-related flags are
trivially applicable to all 6.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
include/libvirt/libvirt-domain-snapshot.h
src/libvirt-domain-snapshot.c