[libvirt PATCH v2 20/24] virdomainmomentobjlist: introduce virDomainMomentIsAncestor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/virdomainmomentobjlist.c | 17 +++++++++++++++++
 src/conf/virdomainmomentobjlist.h |  4 ++++
 src/libvirt_private.syms          |  1 +
 3 files changed, 22 insertions(+)

diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentobjlist.c
index e5cdd9a141..ea9850df8c 100644
--- a/src/conf/virdomainmomentobjlist.c
+++ b/src/conf/virdomainmomentobjlist.c
@@ -582,3 +582,20 @@ virDomainMomentFindLeaf(virDomainMomentObjList *list)
         return moment;
     return NULL;
 }
+
+
+/* Check if @moment is descendant of @ancestor. */
+bool
+virDomainMomentIsAncestor(virDomainMomentObj *moment,
+                          virDomainMomentObj *ancestor)
+{
+    if (moment == ancestor)
+        return false;
+
+    for (moment = moment->parent; moment; moment = moment->parent) {
+        if (moment == ancestor)
+            return true;
+    }
+
+    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 2b1d4e4512..2f4ab607e5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1221,6 +1221,7 @@ virDomainMomentDropChildren;
 virDomainMomentDropParent;
 virDomainMomentForEachChild;
 virDomainMomentForEachDescendant;
+virDomainMomentIsAncestor;
 virDomainMomentMoveChildren;
 virDomainMomentObjFree;
 virDomainMomentObjNew;
-- 
2.41.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux