[libvirt] [PATCH libvirt-java 4/7] Overload Domain.snapshotListNames with a method that has an addition flags argument.

Wido den Hollander wido at widodh.nl
Sun Jan 13 18:09:26 UTC 2013


This commit also adds virDomainSnapshotListFlags which is used by various snapshot
related methods.

Signed-off-by: Wido den Hollander <wido at widodh.nl>
---
 src/main/java/org/libvirt/Domain.java |   54 +++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index 8f4d9da..da03c27 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -87,6 +87,40 @@ public class Domain {
         static final int SNAPSHOTS_METADATA = (1 << 1);
     }
 
+    static final class SnapshotListFlags {
+        /**
+         * Filter by snapshots with no parents, when listing a domain
+         */
+        static final int ROOTS       = (1 << 0);
+
+        /**
+         * List all descendants, not just children, when listing a snapshot
+         */
+        static final int DESCENDANTS = (1 << 0);
+
+        /** For historical reasons, groups do not use contiguous bits. */
+
+        /**
+         * Filter by snapshots with no children
+         */
+        static final int LEAVES      = (1 << 2);
+
+        /**
+         * Filter by snapshots that have children
+         */
+        static final int NO_LEAVES   = (1 << 3);
+
+        /**
+         * Filter by snapshots which have metadata
+         */
+        static final int METADATA    = (1 << 1);
+
+        /**
+         * Filter by snapshots with no metadata
+         */
+        static final int NO_METADATA = (1 << 4);
+    }
+
     /**
      * the native virDomainPtr.
      */
@@ -1050,7 +1084,7 @@ public class Domain {
     }
 
     /**
-     * Collect the list of domain snapshots for the given domain.
+     * Collect the list of domain snapshots for the given domain. With the option to pass flags
      *
      * @see <a
      *      href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListNames">Libvirt
@@ -1058,13 +1092,13 @@ public class Domain {
      * @return The list of names, or null if an error
      * @throws LibvirtException
      */
-    public String[] snapshotListNames() throws LibvirtException {
+    public String[] snapshotListNames(int flags) throws LibvirtException {
         String[] returnValue = null;
         int num = snapshotNum();
         if (num >= 0) {
             returnValue = new String[num];
             if (num > 0) {
-                libvirt.virDomainSnapshotListNames(VDP, returnValue, num, 0);
+                libvirt.virDomainSnapshotListNames(VDP, returnValue, num, flags);
                 processError();
             }
         }
@@ -1072,6 +1106,20 @@ public class Domain {
     }
 
     /**
+     * Collect the list of domain snapshots for the given domain.
+     * This method is here for backwards compatibility.
+     *
+     * @see <a
+     *      href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListNames">Libvirt
+     *      Documentation</a>
+     * @return The list of names, or null if an error
+     * @throws LibvirtException
+     */
+    public String[] snapshotListNames() throws LibvirtException {
+        return snapshotListNames(0);
+    }
+
+    /**
      * Retrieve a snapshot by name
      *
      * @see <a
-- 
1.7.9.5




More information about the libvir-list mailing list