[PATCH libvirt-java 3/7] Implement virDomainUndefineFlags by overloading the existing undefine method

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

 



We divert from the one-on-one mapping rule here by not adding the undefineFlags() method

Signed-off-by: Wido den Hollander <wido@xxxxxxxxx>
---
 src/main/java/org/libvirt/Domain.java      |   24 ++++++++++++++++++++++++
 src/main/java/org/libvirt/jna/Libvirt.java |    1 +
 2 files changed, 25 insertions(+)

diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index 3da6f56..8f4d9da 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -76,6 +76,17 @@ public class Domain {
         static final int VIR_DOMAIN_XML_UPDATE_CPU   = (1 << 2); /* update guest CPU requirements according to host CPU */
     }
 
+    static final class UndefineFlags {
+        /**
+         * Also remove any managed save
+         */
+        static final int MANAGED_SAVE = (1 << 0);
+        /**
+         * If last use of domain, then also remove any snapshot metadata
+         */
+        static final int SNAPSHOTS_METADATA = (1 << 1);
+    }
+
     /**
      * the native virDomainPtr.
      */
@@ -1118,6 +1129,19 @@ public class Domain {
     }
 
     /**
+     * Undefines this domain but does not stop if it it is running. With option for passing flags
+     *
+     * @see <a href="http://libvirt.org/html/libvirt-libvirt.html#virDomainUndefineFlags";>Libvirt Documentation</a>
+     * @param flags
+     *            flags for undefining the domain. See virDomainUndefineFlagsValues for more information
+     * @throws LibvirtException
+    */
+    public void undefine(int flags) throws LibvirtException {
+        libvirt.virDomainUndefineFlags(VDP, flags);
+        processError();
+    }
+
+    /**
      * Change a virtual device on a domain
      *
      * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainUpdateDeviceFlags";>Libvirt Documentation</a>
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index 8262cb9..b814cab 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -240,6 +240,7 @@ public interface Libvirt extends Library {
     int virDomainSuspend(DomainPointer virDomainPtr);
     int virDomainUpdateDeviceFlags(DomainPointer virDomainPtr, String xml, int flags);
     int virDomainUndefine(DomainPointer virDomainPtr);
+    int virDomainUndefineFlags(DomainPointer virDomainPtr, int flags);
 
     // Network functions
     int virNetworkCreate(NetworkPointer virConnectPtr);
-- 
1.7.9.5

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