[libvirt PATCH 17/20] virdomainmomentobjlist: introduce virDomainMomentIsAncestor
Peter Krempa
pkrempa at redhat.com
Tue Apr 4 14:47:55 UTC 2023
On Mon, Mar 13, 2023 at 16:42:18 +0100, Pavel Hrdina wrote:
> This new helper will allow us to check if we are able to delete external
> snapshot after user did revert to non-leaf snapshot.
>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
> src/conf/virdomainmomentobjlist.c | 21 +++++++++++++++++++++
> src/conf/virdomainmomentobjlist.h | 4 ++++
> src/libvirt_private.syms | 1 +
> 3 files changed, 26 insertions(+)
>
> diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentobjlist.c
> index f19ec3319a..0c520fb173 100644
> --- a/src/conf/virdomainmomentobjlist.c
> +++ b/src/conf/virdomainmomentobjlist.c
> @@ -582,3 +582,24 @@ virDomainMomentFindLeaf(virDomainMomentObjList *list)
> return moment;
> return NULL;
> }
> +
> +
> +bool
> +virDomainMomentIsAncestor(virDomainMomentObj *moment,
> + virDomainMomentObj *ancestor)
> +{
> + if (!moment)
> + return false;
for (moment = moment->parent; moment; moment = moment->parent) {
if (moment == ancestor)
return true;
}
return false;
This should be sufficient IIUC to replace the condition and the loop,
right?
Either way:
Reviewed-by: Peter Krempa <pkrempa at redhat.com>
Consider documenting expectations though.
More information about the libvir-list
mailing list