On 1/9/20 12:21 PM, Peter Krempa wrote:
The algorithm is used in two places to find the parent checkpoint object which contains given disk and then uses data from the disk. Additionally the code is written in a very non-obvious way. Factor out the lookup of the disk into a function which also simplifies the callers. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_checkpoint.c | 129 ++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 58 deletions(-)
Thank you. I noticed the repetition when I was preparing my v10 of incremental backup, but did not manage to factor it out cleanly like this.
+/** + * qemuCheckpointFindActiveDiskInParent: + * @vm: domain object + * @from: starting moment object + * @diskname: name (target) of the disk to find + * + * Find the first checkpoint starting from @from continuing through parents + * of the checkpoint which describes disk @diskname. Return the pointer to the + * definition of the disk. + */ +static virDomainCheckpointDiskDef * +qemuCheckpointFindActiveDiskInParent(virDomainObjPtr vm, + virDomainMomentObjPtr from, + const char *diskname) +{
Reviewed-by: Eric Blake <eblake@xxxxxxxxxx> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org