
On Sat, Jul 06, 2019 at 22:56:05 -0500, Eric Blake wrote:
Create a new file for managing a list of checkpoint objects, borrowing heavily from existing virDomainSnapshotObjList paradigms.
Note that while checkpoints definitely have a use case for multiple
snapshots?
children to a single parent (create a base snapshot, create a child snapshot, revert to the base, then create another child snapshot), it's harder to predict how checkpoints will play out with reverting to prior points in time. Thus, in initial use, we may find that in a list of checkpoints, you never have more than one child. However, as the snapshot machinery is already generic, it is easier to reuse the generic machinery that tracks relations between domain moments than it is to open-code a new list-management scheme just for checkpoints.
Similarly, although the initial checkpoint implementation in qemu will only support a single current checkpoint, it is conceivable that a future hypervisor implementation could expose multiple current checkpoints in differential backup scenarios - the API is prepared for this by exposing whether a checkpoint is current via the XML description and via a ListAll filter. But for now, living with the generic code supporting only a single current checkpoint is easier than reworking that aspect of the code.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
[...]
diff --git a/src/conf/virdomaincheckpointobjlist.c b/src/conf/virdomaincheckpointobjlist.c new file mode 100644 index 0000000000..2bf91f3d5f --- /dev/null +++ b/src/conf/virdomaincheckpointobjlist.c @@ -0,0 +1,232 @@
[...]
+static int +virDomainCheckpointObjListGetNames(virDomainCheckpointObjListPtr checkpoints, + virDomainMomentObjPtr from, + char **const names, + int maxnames, + unsigned int flags) +{ + /* We intentionally chose our public flags to match the common flags */ + verify(VIR_DOMAIN_CHECKPOINT_LIST_ROOTS == + (int) VIR_DOMAIN_MOMENT_LIST_ROOTS); + verify(VIR_DOMAIN_CHECKPOINT_LIST_TOPOLOGICAL == + (int) VIR_DOMAIN_MOMENT_LIST_TOPOLOGICAL); + verify(VIR_DOMAIN_CHECKPOINT_LIST_LEAVES == + (int) VIR_DOMAIN_MOMENT_LIST_LEAVES); + verify(VIR_DOMAIN_CHECKPOINT_LIST_NO_LEAVES == + (int) VIR_DOMAIN_MOMENT_LIST_NO_LEAVES); + verify(VIR_DOMAIN_CHECKPOINT_LIST_CURRENT == + (int) VIR_DOMAIN_MOMENT_LIST_CURRENT); + verify(VIR_DOMAIN_CHECKPOINT_LIST_NO_CURRENT == + (int) VIR_DOMAIN_MOMENT_LIST_NO_CURRENT);
In v8 I asked for these to be put where VIR_DOMAIN_CHECKPOINT_LIST_* are defined rather than randomly into the code. ACK with the above addressed.