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;
+
+ if (moment == ancestor)
+ return false;
+
+ do {
+ moment = moment->parent;
+
+ if (moment == ancestor)
+ return true;
+ } while (moment);
+
+ return false;
+}
diff --git a/src/conf/virdomainmomentobjlist.h b/src/conf/virdomainmomentobjlist.h
index d2ab3b46b1..2ea6b181c0 100644
--- a/src/conf/virdomainmomentobjlist.h
+++ b/src/conf/virdomainmomentobjlist.h
@@ -157,3 +157,7 @@ virDomainMomentCheckCycles(virDomainMomentObjList *list,
virDomainMomentObj *
virDomainMomentFindLeaf(virDomainMomentObjList *list);
+
+bool
+virDomainMomentIsAncestor(virDomainMomentObj *moment,
+ virDomainMomentObj *ancestor);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dd752ba55c..8a724ef241 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1222,6 +1222,7 @@ virDomainMomentDropChildren;
virDomainMomentDropParent;
virDomainMomentForEachChild;
virDomainMomentForEachDescendant;
+virDomainMomentIsAncestor;
virDomainMomentMoveChildren;
virDomainMomentObjFree;
virDomainMomentObjNew;
--
2.39.2