[PATCHv2 3/4] snapshot: implement new filter sets

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

 



Relatively straight-forward.  And since qemu was already using
VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, with 6 different APIs all calling
into this common code, I've instantly added all 5 flags to 6 APIs.

* src/conf/snapshot_conf.h (VIR_DOMAIN_SNAPSHOT_FILTERS_ALL):
Enable new filters.
* src/conf/snapshot_conf.c (virDomainSnapshotObjListGetNames):
Prep the new flags.
(virDomainSnapshotObjListCopyNames): Actually do the filtering.
---
 src/conf/snapshot_conf.c | 30 ++++++++++++++++++++++++++++--
 src/conf/snapshot_conf.h |  4 +++-
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index aa2b526..1ee4017 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -739,6 +739,26 @@ static void virDomainSnapshotObjListCopyNames(void *payload,
     if ((data->flags & VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES) && !obj->nchildren)
         return;

+    if (data->flags & VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS) {
+        if (!(data->flags & VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE) &&
+            obj->def->state == VIR_DOMAIN_SHUTOFF)
+            return;
+        if (!(data->flags & VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY) &&
+            obj->def->state == VIR_DOMAIN_DISK_SNAPSHOT)
+            return;
+        if (!(data->flags & VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE) &&
+            obj->def->state != VIR_DOMAIN_SHUTOFF &&
+            obj->def->state != VIR_DOMAIN_DISK_SNAPSHOT)
+            return;
+    }
+
+    if ((data->flags & VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL) &&
+        virDomainSnapshotIsExternal(obj))
+        return;
+    if ((data->flags & VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL) &&
+        !virDomainSnapshotIsExternal(obj))
+        return;
+
     if (data->names && data->count < data->maxnames &&
         !(data->names[data->count] = strdup(obj->def->name))) {
         data->error = true;
@@ -780,11 +800,17 @@ virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots,
         return 0;
     data.flags &= ~VIR_DOMAIN_SNAPSHOT_FILTERS_METADATA;

-    /* For ease of coding the visitor, it is easier to zero the LEAVES
-     * group if both bits are set.  */
+    /* For ease of coding the visitor, it is easier to zero each group
+     * where all of the bits are set.  */
     if ((data.flags & VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES) ==
         VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES)
         data.flags &= ~VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES;
+    if ((data.flags & VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS) ==
+        VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS)
+        data.flags &= ~VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS;
+    if ((data.flags & VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION) ==
+        VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION)
+        data.flags &= ~VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION;

     if (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) {
         if (from->def)
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index e291ddd..b0f8760 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -156,7 +156,9 @@ void virDomainSnapshotDropParent(virDomainSnapshotObjPtr snapshot);

 # define VIR_DOMAIN_SNAPSHOT_FILTERS_ALL                \
                (VIR_DOMAIN_SNAPSHOT_FILTERS_METADATA  | \
-                VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES)
+                VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES    | \
+                VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS    | \
+                VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION)

 int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
                            virDomainSnapshotObjPtr from,
-- 
1.7.11.7

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[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]