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(a)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(a)redhat.com>
Consider documenting expectations though.