[libvirt] Series of patches for libvirt-java

Hello, This series of patches adds functionality to libvirt-java for: * block device resizing * snapshot handling * domain migration All these patches originate from the Apache CloudStack project and were written during development of new featurs for CloudStack. Thank you, Wido

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/jna/Libvirt.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index e68d9ed..dbd8f6c 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -168,6 +168,7 @@ public interface Libvirt extends Library { public int virDomainAttachDevice(DomainPointer virDomainPtr, String deviceXML); public int virDomainAttachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags); public int virDomainBlockStats(DomainPointer virDomainPtr, String path, virDomainBlockStats stats, int size); + public int virDomainBlockResize(DomainPointer virDomainPtr, String disk, NativeLong size, int flags); public int virDomainCoreDump(DomainPointer virDomainPtr, String to, int flags); public int virDomainCreate(DomainPointer virDomainPtr); public int virDomainCreateWithFlags(DomainPointer virDomainPtr, int flags); @@ -313,6 +314,7 @@ public interface Libvirt extends Library { public StorageVolPointer virStorageVolLookupByName(StoragePoolPointer storagePoolPtr, String name); public StorageVolPointer virStorageVolLookupByPath(ConnectionPointer virConnectPtr, String path); public int virStorageVolWipe(StorageVolPointer storageVolPtr, int flags); + public int virStorageVolResize(StorageVolPointer storageVolPtr, NativeLong capacity, int flags); // Interface Methods public int virInterfaceCreate(InterfacePointer virDevicePointer); -- 1.7.9.5

At Sat, 5 Jan 2013 12:48:18 +0100, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/jna/Libvirt.java | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index e68d9ed..dbd8f6c 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -168,6 +168,7 @@ public interface Libvirt extends Library { public int virDomainAttachDevice(DomainPointer virDomainPtr, String deviceXML); public int virDomainAttachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags); public int virDomainBlockStats(DomainPointer virDomainPtr, String path, virDomainBlockStats stats, int size); + public int virDomainBlockResize(DomainPointer virDomainPtr, String disk, NativeLong size, int flags); public int virDomainCoreDump(DomainPointer virDomainPtr, String to, int flags); public int virDomainCreate(DomainPointer virDomainPtr); public int virDomainCreateWithFlags(DomainPointer virDomainPtr, int flags); @@ -313,6 +314,7 @@ public interface Libvirt extends Library { public StorageVolPointer virStorageVolLookupByName(StoragePoolPointer storagePoolPtr, String name); public StorageVolPointer virStorageVolLookupByPath(ConnectionPointer virConnectPtr, String path); public int virStorageVolWipe(StorageVolPointer storageVolPtr, int flags); + public int virStorageVolResize(StorageVolPointer storageVolPtr, NativeLong capacity, int flags);
// Interface Methods public int virInterfaceCreate(InterfacePointer virDevicePointer);
NACK since the wrapping is wrong. The native type of the capacity parameter is "unsigned long long". When wrapping this type using JNA one should just use the Java "long" type. See https://github.com/twall/jna/blob/master/www/Mappings.md Btw, using the "public" modifier in interfaces is discouraged in Java (see JLS 9.4). I'll push a patch shortly removing those modifiers. So, please refrain from using those in new code. Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/StorageVol.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/org/libvirt/StorageVol.java b/src/main/java/org/libvirt/StorageVol.java index 1bed6e1..66e647f 100644 --- a/src/main/java/org/libvirt/StorageVol.java +++ b/src/main/java/org/libvirt/StorageVol.java @@ -4,6 +4,8 @@ import org.libvirt.jna.Libvirt; import org.libvirt.jna.StoragePoolPointer; import org.libvirt.jna.StorageVolPointer; import org.libvirt.jna.virStorageVolInfo; +import com.sun.jna.Native; +import com.sun.jna.NativeLong; /** * An acutal storage bucket. @@ -208,4 +210,21 @@ public class StorageVol { processError(); return returnValue; } + + /** + * Resize a volume + * + * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virStorageVolResize">Libvirt Documentation</a> + * @param capacity + * new capacity for volume + * @param flags + * flags for resizing, see libvirt API for exact flags + * @return 0 on success, or -1 on error + * @throws LibvirtException + */ + public int resize(NativeLong capacity, int flags) throws LibvirtException { + int returnValue = libvirt.virStorageVolResize(VSVP, capacity, flags); + processError(); + return returnValue; + } } -- 1.7.9.5

At Sat, 5 Jan 2013 12:48:19 +0100, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/StorageVol.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/src/main/java/org/libvirt/StorageVol.java b/src/main/java/org/libvirt/StorageVol.java index 1bed6e1..66e647f 100644 --- a/src/main/java/org/libvirt/StorageVol.java +++ b/src/main/java/org/libvirt/StorageVol.java @@ -4,6 +4,8 @@ import org.libvirt.jna.Libvirt; import org.libvirt.jna.StoragePoolPointer; import org.libvirt.jna.StorageVolPointer; import org.libvirt.jna.virStorageVolInfo; +import com.sun.jna.Native;
This import is unused.
+import com.sun.jna.NativeLong;
/** * An acutal storage bucket. @@ -208,4 +210,21 @@ public class StorageVol { processError(); return returnValue; } + + /** + * Resize a volume + * + * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virStorageVolResize">Libvirt Documentation</a> + * @param capacity + * new capacity for volume + * @param flags + * flags for resizing, see libvirt API for exact flags + * @return 0 on success, or -1 on error + * @throws LibvirtException + */ + public int resize(NativeLong capacity, int flags) throws LibvirtException { + int returnValue = libvirt.virStorageVolResize(VSVP, capacity, flags); + processError(); + return returnValue; + }
JNA types should not be exposed to the public API, IMHO. So, using NativeLong in the parameter list is not good. And see my comment for 1/9. Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index fc1f665..4b4c572 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -193,6 +193,24 @@ public class Domain { } /** + * Resize a block device of domain while the domain is running. + * + * @param disk + * path to the block image, or shorthand (like vda) + * @param size + * the new size of the block devices + * @param flags + * when set to 1, units of size is in bytes instead of KiloBytes + * @return 0 on succes, -1 on error + * @throws LibvirtException + */ + public int blockResize(String disk, NativeLong size, int flags) throws LibvirtException { + int returnValue = libvirt.virDomainBlockResize(VDP, disk, size, flags); + processError(); + return returnValue; + } + + /** * Dumps the core of this domain on a given file for analysis. Note that for * remote Xen Daemon the file path will be interpreted in the remote host. * -- 1.7.9.5

At Sat, 5 Jan 2013 12:48:20 +0100, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index fc1f665..4b4c572 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -193,6 +193,24 @@ public class Domain { }
/** + * Resize a block device of domain while the domain is running. + * + * @param disk + * path to the block image, or shorthand (like vda) + * @param size + * the new size of the block devices + * @param flags + * when set to 1, units of size is in bytes instead of KiloBytes + * @return 0 on succes, -1 on error
This is not true as this method will throw an exception on error, it should never return -1. Just use return type void instead. Either it will work or throw an exception.
+ * @throws LibvirtException + */ + public int blockResize(String disk, NativeLong size, int flags) throws LibvirtException { + int returnValue = libvirt.virDomainBlockResize(VDP, disk, size, flags); + processError(); + return returnValue; + }
Same comment applies to NativeLong as for patch 2/9. Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index 4b4c572..e0be43d 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -997,18 +997,20 @@ public class Domain { /** * Creates a new snapshot of a domain based on the snapshot xml contained in - * xmlDesc. + * xmlDesc with the option to pass flags * * @see <a * href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotCreateXML">Libvirt * Documentation</a> * @param xmlDesc * string containing an XML description of the domain + * @param flags + * flags for creating the snapshot, see the virDomainSnapshotCreateFlags for the flag options * @return the snapshot, or null on Error * @throws LibvirtException */ - public DomainSnapshot snapshotCreateXML(String xmlDesc) throws LibvirtException { - DomainSnapshotPointer ptr = libvirt.virDomainSnapshotCreateXML(VDP, xmlDesc, 0); + public DomainSnapshot snapshotCreateXML(String xmlDesc, int flags) throws LibvirtException { + DomainSnapshotPointer ptr = libvirt.virDomainSnapshotCreateXML(VDP, xmlDesc, flags); processError(); DomainSnapshot returnValue = null; if (ptr != null) { @@ -1018,6 +1020,22 @@ public class Domain { } /** + * Creates a new snapshot of a domain based on the snapshot xml contained in + * xmlDesc. + * + * @see <a + * href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotCreateXML">Libvirt + * Documentation</a> + * @param xmlDesc + * string containing an XML description of the domain + * @return the snapshot, or null on Error + * @throws LibvirtException + */ + public DomainSnapshot snapshotCreateXML(String xmlDesc) throws LibvirtException { + return snapshotCreateXML(xmlDesc, 0); + } + + /** * Get the current snapshot for a domain, if any. * * @see <a -- 1.7.9.5

At Sat, 5 Jan 2013 12:48:21 +0100, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index 4b4c572..e0be43d 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -997,18 +997,20 @@ public class Domain {
/** * Creates a new snapshot of a domain based on the snapshot xml contained in - * xmlDesc. + * xmlDesc with the option to pass flags
Um, this sounds a bit odd to me, but I'm no native speaker. Otherwise, looks good. ACK Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 15 +++++++++++++++ src/main/java/org/libvirt/jna/Libvirt.java | 1 + 2 files changed, 16 insertions(+) diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index e0be43d..d393960 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -1134,6 +1134,21 @@ public class Domain { } /** + * undefines this domain but does not stop if it it is running. With flags option + * + * @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 + * @return 0 on success, -1 on error + * @throws LibvirtException + */ + public int undefineFlags(int flags) throws LibvirtException { + int returnValue = libvirt.virDomainUndefineFlags(VDP, flags); + processError(); + return returnValue; + } + + /** * 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 dbd8f6c..2bbc8c3 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -228,6 +228,7 @@ public interface Libvirt extends Library { public int virDomainSuspend(DomainPointer virDomainPtr); public int virDomainUpdateDeviceFlags(DomainPointer virDomainPtr, String xml, int flags); public int virDomainUndefine(DomainPointer virDomainPtr); + public int virDomainUndefineFlags(DomainPointer virDomainPtr, int flags); // Network functions public ConnectionPointer virNetworkGetConnect(NetworkPointer virnetworkPtr); -- 1.7.9.5

At Sat, 5 Jan 2013 12:48:22 +0100, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 15 +++++++++++++++ src/main/java/org/libvirt/jna/Libvirt.java | 1 + 2 files changed, 16 insertions(+)
diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index e0be43d..d393960 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -1134,6 +1134,21 @@ public class Domain { }
/** + * undefines this domain but does not stop if it it is running. With flags option
Undefines (capital u) s/if it/it if/
+ * @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 + * @return 0 on success, -1 on error
Exception on error, never -1. Just use return type void.
+ public int undefineFlags(int flags) throws LibvirtException {
Should we take advantage of Java's method overloading capability here? I propose to divert from the mapping rules and just overload the undefine method with an additional parameter.
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index dbd8f6c..2bbc8c3 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -228,6 +228,7 @@ public interface Libvirt extends Library { public int virDomainSuspend(DomainPointer virDomainPtr); public int virDomainUpdateDeviceFlags(DomainPointer virDomainPtr, String xml, int flags); public int virDomainUndefine(DomainPointer virDomainPtr); + public int virDomainUndefineFlags(DomainPointer virDomainPtr, int flags);
Please drop the public modifier. Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

On 01/07/2013 06:55 AM, Claudio Bley wrote:
+ public int undefineFlags(int flags) throws LibvirtException {
Should we take advantage of Java's method overloading capability here?
I propose to divert from the mapping rules and just overload the undefine method with an additional parameter.
Agreed. For higher-level languages that support overloads and/or default parameters, we don't need to expose the poor naming goop that lower-level C is stuck with. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index d393960..932f56c 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -1055,21 +1055,23 @@ public class Domain { } /** - * Collect the list of domain snapshots for the given domain. + * Collect the list of domain snapshots for the given domain. With flags option * * @see <a * href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListNames">Libvirt * Documentation</a> + * @param flags + * flags for listing snapshot names. See virDomainSnapshotListFlags for more information * @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(); } } @@ -1077,6 +1079,19 @@ public class Domain { } /** + * Collect the list of domain snapshots for the given domain. + * + * @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

This enables use a different XML for running the guest on the target host. Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 54 ++++++++++++++++++++++++++-- src/main/java/org/libvirt/jna/Libvirt.java | 2 ++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index 932f56c..03afa0e 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -760,6 +760,8 @@ public class Domain { * * @param dconn * destination host (a Connect object) + * @param dxml + * (optional) XML config for launching guest on target * @param flags * flags * @param dname @@ -773,13 +775,61 @@ public class Domain { * scope of the destination connection (dconn). * @throws LibvirtException */ - public Domain migrate(Connect dconn, long flags, String dname, String uri, long bandwidth) throws LibvirtException { - DomainPointer newPtr = libvirt.virDomainMigrate(VDP, dconn.VCP, new NativeLong(flags), dname, uri, new NativeLong(bandwidth)); + public Domain migrate(Connect dconn, long flags, String dxml, String dname, String uri, long bandwidth) throws LibvirtException { + DomainPointer newPtr = libvirt.virDomainMigrate2(VDP, dconn.VCP, dxml, new NativeLong(flags), dname, uri, new NativeLong(bandwidth)); processError(); return new Domain(dconn, newPtr); } /** + * Migrate this domain object from its current host to the destination host + * given by dconn (a connection to the destination host). Flags may be one + * of more of the following: Domain.VIR_MIGRATE_LIVE Attempt a live + * migration. If a hypervisor supports renaming domains during migration, + * then you may set the dname parameter to the new name (otherwise it keeps + * the same name). If this is not supported by the hypervisor, dname must be + * NULL or else you will get an error. Since typically the two hypervisors + * connect directly to each other in order to perform the migration, you may + * need to specify a path from the source to the destination. This is the + * purpose of the uri parameter.If uri is NULL, then libvirt will try to + * find the best method. Uri may specify the hostname or IP address of the + * destination host as seen from the source, or uri may be a URI giving + * transport, hostname, user, port, etc. in the usual form. Uri should only + * be specified if you want to migrate over a specific interface on the + * remote host. For Qemu/KVM, the uri should be of the form + * "tcp://hostname[:port]". This does not require TCP auth to be setup + * between the connections, since migrate uses a straight TCP connection + * (unless using the PEER2PEER flag, in which case URI should be a full + * fledged libvirt URI). Refer also to driver documentation for the + * particular URIs supported. If set to 0, libvirt will choose a suitable + * default. Some hypervisors do not support this feature and will return an + * error if bandwidth is not 0. To see which features are supported by the + * current hypervisor, see Connect.getCapabilities, + * /capabilities/host/migration_features. There are many limitations on + * migration imposed by the underlying technology - for example it may not + * be possible to migrate between different processors even with the same + * architecture, or between different types of hypervisor. + * + * @param dconn + * destination host (a Connect object) + * @param flags + * flags + * @param dname + * (optional) rename domain to this at destination + * @param uri + * (optional) dest hostname/URI as seen from the source host + * @param bandwidth + * optional) specify migration bandwidth limit in Mbps + * @return the new domain object if the migration was successful, or NULL in + * case of error. Note that the new domain object exists in the + * scope of the destination connection (dconn). + * @throws LibvirtException + */ + public Domain migrate(Connect dconn, long flags, String dname, String uri, long bandwidth) throws LibvirtException { + return migrate(dconn, flags, null, dname, uri, bandwidth); + } + + /** * Sets maximum tolerable time for which the domain is allowed to be paused * at the end of live migration. * diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index 2bbc8c3..de2a262 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -209,6 +209,8 @@ public interface Libvirt extends Library { public int virDomainManagedSaveRemove(DomainPointer virDomainPtr, int flags); public DomainPointer virDomainMigrate(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr, NativeLong flags, String dname, String uri, NativeLong bandwidth); + public DomainPointer virDomainMigrate2(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr, + String dxml, NativeLong flags, String dname, String uri, NativeLong bandwidth); public int virDomainMigrateSetMaxDowntime(DomainPointer virDomainPtr, long downtime, int flags); public int virDomainMigrateToURI(DomainPointer virDomainPtr, String duri, NativeLong flags, String dname, NativeLong bandwidth); -- 1.7.9.5

At Sat, 5 Jan 2013 12:48:24 +0100, Wido den Hollander wrote:
This enables use a different XML for running the guest on the target host.
This sentence does not sound right. How about This makes it possible to alter host-specific portions of the domain XML that will be used on the destination host.
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 54 ++++++++++++++++++++++++++-- src/main/java/org/libvirt/jna/Libvirt.java | 2 ++ 2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index 932f56c..03afa0e 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -760,6 +760,8 @@ public class Domain { * * @param dconn * destination host (a Connect object) + * @param dxml + * (optional) XML config for launching guest on target * @param flags * flags * @param dname @@ -773,13 +775,61 @@ public class Domain { * scope of the destination connection (dconn). * @throws LibvirtException */ - public Domain migrate(Connect dconn, long flags, String dname, String uri, long bandwidth) throws LibvirtException { - DomainPointer newPtr = libvirt.virDomainMigrate(VDP, dconn.VCP, new NativeLong(flags), dname, uri, new NativeLong(bandwidth)); + public Domain migrate(Connect dconn, long flags, String dxml, String dname, String uri, long bandwidth) throws LibvirtException { + DomainPointer newPtr = libvirt.virDomainMigrate2(VDP, dconn.VCP, dxml, new NativeLong(flags), dname, uri, new NativeLong(bandwidth)); processError(); return new Domain(dconn, newPtr); }
/** + * Migrate this domain object from its current host to the destination host + * given by dconn (a connection to the destination host). Flags may be one + * of more of the following: Domain.VIR_MIGRATE_LIVE Attempt a live + * migration. If a hypervisor supports renaming domains during migration, + * then you may set the dname parameter to the new name (otherwise it keeps + * the same name). If this is not supported by the hypervisor, dname must be + * NULL or else you will get an error. Since typically the two hypervisors + * connect directly to each other in order to perform the migration, you may + * need to specify a path from the source to the destination. This is the + * purpose of the uri parameter.If uri is NULL, then libvirt will try to + * find the best method. Uri may specify the hostname or IP address of the + * destination host as seen from the source, or uri may be a URI giving + * transport, hostname, user, port, etc. in the usual form. Uri should only + * be specified if you want to migrate over a specific interface on the + * remote host. For Qemu/KVM, the uri should be of the form + * "tcp://hostname[:port]". This does not require TCP auth to be setup + * between the connections, since migrate uses a straight TCP connection + * (unless using the PEER2PEER flag, in which case URI should be a full + * fledged libvirt URI). Refer also to driver documentation for the + * particular URIs supported. If set to 0, libvirt will choose a suitable + * default. Some hypervisors do not support this feature and will return an + * error if bandwidth is not 0. To see which features are supported by the + * current hypervisor, see Connect.getCapabilities, + * /capabilities/host/migration_features. There are many limitations on + * migration imposed by the underlying technology - for example it may not + * be possible to migrate between different processors even with the same + * architecture, or between different types of hypervisor.
Breaking this up into a few paragraphs would be nice. Also, you've re-used the documentation of the old method for the new method having an additional argument. It would be nice to add some words about the new parameter. And while touching this, adding a few paragraph separators would be a bonus.
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index 2bbc8c3..de2a262 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -209,6 +209,8 @@ public interface Libvirt extends Library { public int virDomainManagedSaveRemove(DomainPointer virDomainPtr, int flags); public DomainPointer virDomainMigrate(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr, NativeLong flags, String dname, String uri, NativeLong bandwidth); + public DomainPointer virDomainMigrate2(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr, + String dxml, NativeLong flags, String dname, String uri, NativeLong bandwidth);
Again, please drop the public modifier. Since we're no longer using virDomainMigrate, we might just as well remove it from the JNA interface altogether. Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

The migrateToURI method now uses virDomainMigrateToURI2 so we can support some more features. Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 33 +++++++++++++++++++++++++--- src/main/java/org/libvirt/jna/Libvirt.java | 2 ++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index 03afa0e..6fb1161 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -855,6 +855,35 @@ public class Domain { * href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI"> * virDomainMigrateToURI</a> * + * @param dconnuri + * (optional) URI for target libvirtd if @flags includes VIR_MIGRATE_PEER2PEER + * @param miguri + * (optional) URI for invoking the migration, not if @flags includs VIR_MIGRATE_TUNNELLED + * @param dxml + * (optional) XML config for launching guest on target + * @param flags + * Controls the migrate + * @param dname + * The name at the destnation + * @param bandwidth + * Specify the migration bandwidth + * @return 0 if successful, -1 if not + * @throws LibvirtException + */ + public int migrateToURI(String dconnuri, String miguri, String dxml, long flags, String dname, long bandwidth) throws LibvirtException { + int returnValue = libvirt.virDomainMigrateToURI2(VDP, dconnuri, miguri, dxml, new NativeLong(flags), dname, new NativeLong(bandwidth)); + processError(); + return returnValue; + } + + /** + * Migrate the domain object from its current host to the destination host + * given by duri. + * + * @see <a + * href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI"> + * virDomainMigrateToURI</a> + * * @param uri * The destination URI * @param flags @@ -867,9 +896,7 @@ public class Domain { * @throws LibvirtException */ public int migrateToURI(String uri, long flags, String dname, long bandwidth) throws LibvirtException { - int returnValue = libvirt.virDomainMigrateToURI(VDP, uri, new NativeLong(flags), dname, new NativeLong(bandwidth)); - processError(); - return returnValue; + return migrateToURI(uri, null, null, flags, dname, bandwidth); } /** diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index de2a262..27011d9 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -214,6 +214,8 @@ public interface Libvirt extends Library { public int virDomainMigrateSetMaxDowntime(DomainPointer virDomainPtr, long downtime, int flags); public int virDomainMigrateToURI(DomainPointer virDomainPtr, String duri, NativeLong flags, String dname, NativeLong bandwidth); + public int virDomainMigrateToURI2(DomainPointer virDomainPtr, String dconnuri, String miguri, + String dxml, NativeLong flags, String dname, NativeLong bandwidth); public int virDomainMemoryStats(DomainPointer virDomainPtr, virDomainMemoryStats[] stats, int nr_stats, int flags); public int virDomainPinVcpu(DomainPointer virDomainPtr, int vcpu, byte[] cpumap, int maplen); public int virDomainReboot(DomainPointer virDomainPtr, int flags); -- 1.7.9.5

At Sat, 5 Jan 2013 12:48:25 +0100, Wido den Hollander wrote:
The migrateToURI method now uses virDomainMigrateToURI2 so we can support some more features.
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Domain.java | 33 +++++++++++++++++++++++++--- src/main/java/org/libvirt/jna/Libvirt.java | 2 ++ 2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java index 03afa0e..6fb1161 100644 --- a/src/main/java/org/libvirt/Domain.java +++ b/src/main/java/org/libvirt/Domain.java @@ -855,6 +855,35 @@ public class Domain { * href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI"> * virDomainMigrateToURI</a> * + * @param dconnuri + * (optional) URI for target libvirtd if @flags includes VIR_MIGRATE_PEER2PEER + * @param miguri + * (optional) URI for invoking the migration, not if @flags includs VIR_MIGRATE_TUNNELLED + * @param dxml + * (optional) XML config for launching guest on target + * @param flags + * Controls the migrate + * @param dname + * The name at the destnation + * @param bandwidth + * Specify the migration bandwidth + * @return 0 if successful, -1 if not
Actually no. It throws an exception in case of an error. I think it would be awkward introducing a new method with a known glitch now, just in order to fix it later.
+ * @throws LibvirtException + */ + public int migrateToURI(String dconnuri, String miguri, String dxml, long flags, String dname, long bandwidth) throws LibvirtException { + int returnValue = libvirt.virDomainMigrateToURI2(VDP, dconnuri, miguri, dxml, new NativeLong(flags), dname, new NativeLong(bandwidth)); + processError(); + return returnValue; + } + + /** + * Migrate the domain object from its current host to the destination host + * given by duri. + * + * @see <a + * href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainMigrateToURI"> + * virDomainMigrateToURI</a> + * * @param uri * The destination URI * @param flags @@ -867,9 +896,7 @@ public class Domain { * @throws LibvirtException */ public int migrateToURI(String uri, long flags, String dname, long bandwidth) throws LibvirtException { - int returnValue = libvirt.virDomainMigrateToURI(VDP, uri, new NativeLong(flags), dname, new NativeLong(bandwidth)); - processError(); - return returnValue; + return migrateToURI(uri, null, null, flags, dname, bandwidth); }
/** diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index de2a262..27011d9 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -214,6 +214,8 @@ public interface Libvirt extends Library { public int virDomainMigrateSetMaxDowntime(DomainPointer virDomainPtr, long downtime, int flags); public int virDomainMigrateToURI(DomainPointer virDomainPtr, String duri, NativeLong flags, String dname, NativeLong bandwidth); + public int virDomainMigrateToURI2(DomainPointer virDomainPtr, String dconnuri, String miguri, + String dxml, NativeLong flags, String dname, NativeLong bandwidth); public int virDomainMemoryStats(DomainPointer virDomainPtr, virDomainMemoryStats[] stats, int nr_stats, int flags); public int virDomainPinVcpu(DomainPointer virDomainPtr, int vcpu, byte[] cpumap, int maplen); public int virDomainReboot(DomainPointer virDomainPtr, int flags);
You know the drill: please drop the public modifier ;-) And just remove the virDomainMigrateToURI in favor of virDomainMigrateToURI2. Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

On 01/05/2013 04:48 AM, Wido den Hollander wrote:
The migrateToURI method now uses virDomainMigrateToURI2 so we can support some more features.
+ public int migrateToURI(String dconnuri, String miguri, String dxml, long flags, String dname, long bandwidth) throws LibvirtException { + int returnValue = libvirt.virDomainMigrateToURI2(VDP, dconnuri, miguri, dxml, new NativeLong(flags), dname, new NativeLong(bandwidth)); + processError(); + return returnValue; + } +
*/ public int migrateToURI(String uri, long flags, String dname, long bandwidth) throws LibvirtException { - int returnValue = libvirt.virDomainMigrateToURI(VDP, uri, new NativeLong(flags), dname, new NativeLong(bandwidth)); - processError(); - return returnValue; + return migrateToURI(uri, null, null, flags, dname, bandwidth); }
When you make changes like this, you need to worry about back-compat issues. Remember, older versions of libvirt did not have virDomainMigreateToURI2, so you may be effectively turning the old migrateToURI(4-args) into a call to a new API, which will break when targetting older libvirt, whereas if you kept it as a call to the older libvirt.virDomainMigrateToURI, the older libvirt can still do the migration. There may be more patches like this in your series, but in general, you should favor forwarding calls to the older API, not the newer API, so that the clients will work against as many libvirt versions as possible. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

At Mon, 07 Jan 2013 17:10:16 -0700, Eric Blake wrote:
On 01/05/2013 04:48 AM, Wido den Hollander wrote:
The migrateToURI method now uses virDomainMigrateToURI2 so we can support some more features.
+ public int migrateToURI(String dconnuri, String miguri, String dxml, long flags, String dname, long bandwidth) throws LibvirtException { + int returnValue = libvirt.virDomainMigrateToURI2(VDP, dconnuri, miguri, dxml, new NativeLong(flags), dname, new NativeLong(bandwidth)); + processError(); + return returnValue; + } +
*/ public int migrateToURI(String uri, long flags, String dname, long bandwidth) throws LibvirtException { - int returnValue = libvirt.virDomainMigrateToURI(VDP, uri, new NativeLong(flags), dname, new NativeLong(bandwidth)); - processError(); - return returnValue; + return migrateToURI(uri, null, null, flags, dname, bandwidth); }
When you make changes like this, you need to worry about back-compat issues. Remember, older versions of libvirt did not have virDomainMigreateToURI2, so you may be effectively turning the old migrateToURI(4-args) into a call to a new API, which will break when targetting older libvirt, whereas if you kept it as a call to the older libvirt.virDomainMigrateToURI, the older libvirt can still do the migration.
I already checked this. (Wido, it would have been nice if you said when this libvirt function came into existence, so review would have been easier.) Currently, libvirt 0.9.12 is required by libvirt-java evidenced by this line in build.properties: libvirt.required=0.9.12 virDomainMigreateToURI2 was introduced in libvirt 0.9.2.
There may be more patches like this in your series, but in general, you should favor forwarding calls to the older API, not the newer API, so that the clients will work against as many libvirt versions as possible.
OK, this makes sense. But where do we draw the line? Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

On 01/08/2013 09:18 AM, Claudio Bley wrote:
At Mon, 07 Jan 2013 17:10:16 -0700, Eric Blake wrote:
On 01/05/2013 04:48 AM, Wido den Hollander wrote:
The migrateToURI method now uses virDomainMigrateToURI2 so we can support some more features.
+ public int migrateToURI(String dconnuri, String miguri, String dxml, long flags, String dname, long bandwidth) throws LibvirtException { + int returnValue = libvirt.virDomainMigrateToURI2(VDP, dconnuri, miguri, dxml, new NativeLong(flags), dname, new NativeLong(bandwidth)); + processError(); + return returnValue; + } +
*/ public int migrateToURI(String uri, long flags, String dname, long bandwidth) throws LibvirtException { - int returnValue = libvirt.virDomainMigrateToURI(VDP, uri, new NativeLong(flags), dname, new NativeLong(bandwidth)); - processError(); - return returnValue; + return migrateToURI(uri, null, null, flags, dname, bandwidth); }
When you make changes like this, you need to worry about back-compat issues. Remember, older versions of libvirt did not have virDomainMigreateToURI2, so you may be effectively turning the old migrateToURI(4-args) into a call to a new API, which will break when targetting older libvirt, whereas if you kept it as a call to the older libvirt.virDomainMigrateToURI, the older libvirt can still do the migration.
I already checked this. (Wido, it would have been nice if you said when this libvirt function came into existence, so review would have been easier.)
Sorry for that. Thanks for all the feedback you gave, I'll work on a new set of patches which addresses all these points.
Currently, libvirt 0.9.12 is required by libvirt-java evidenced by this line in build.properties:
libvirt.required=0.9.12
virDomainMigreateToURI2 was introduced in libvirt 0.9.2.
There may be more patches like this in your series, but in general, you should favor forwarding calls to the older API, not the newer API, so that the clients will work against as many libvirt versions as possible.
OK, this makes sense. But where do we draw the line?
Indeed. I looked the same up and thought that it should work due to that requirement. Wido
Claudio

On Tue, Jan 08, 2013 at 09:18:30 +0100, Claudio Bley wrote:
At Mon, 07 Jan 2013 17:10:16 -0700, Eric Blake wrote:
On 01/05/2013 04:48 AM, Wido den Hollander wrote:
The migrateToURI method now uses virDomainMigrateToURI2 so we can support some more features.
+ public int migrateToURI(String dconnuri, String miguri, String dxml, long flags, String dname, long bandwidth) throws LibvirtException { + int returnValue = libvirt.virDomainMigrateToURI2(VDP, dconnuri, miguri, dxml, new NativeLong(flags), dname, new NativeLong(bandwidth)); + processError(); + return returnValue; + } +
*/ public int migrateToURI(String uri, long flags, String dname, long bandwidth) throws LibvirtException { - int returnValue = libvirt.virDomainMigrateToURI(VDP, uri, new NativeLong(flags), dname, new NativeLong(bandwidth)); - processError(); - return returnValue; + return migrateToURI(uri, null, null, flags, dname, bandwidth); }
When you make changes like this, you need to worry about back-compat issues. Remember, older versions of libvirt did not have virDomainMigreateToURI2, so you may be effectively turning the old migrateToURI(4-args) into a call to a new API, which will break when targetting older libvirt, whereas if you kept it as a call to the older libvirt.virDomainMigrateToURI, the older libvirt can still do the migration.
I already checked this. (Wido, it would have been nice if you said when this libvirt function came into existence, so review would have been easier.)
Currently, libvirt 0.9.12 is required by libvirt-java evidenced by this line in build.properties:
libvirt.required=0.9.12
virDomainMigreateToURI2 was introduced in libvirt 0.9.2.
Of course, but the requirement applies to client libvirt library that libvirt-java links to. In case of stateful drivers (such as QEMU, LXC, ...), applications use this library to talk to a libvirt daemon which may even run on a remote host and you have no control over its version. Thus, while the libvirt-java requires libvirt 0.9.12, it doesn't mean it can't talk to libvirt daemons that are older (as long as the app does not use anything that was introduced later, of course). That's how it works in general. However, the migration APIs are a bit special since they actually contain some additional logic that decides what API calls need to be made depending on arguments and flags. In other words, the code in libvirt library will make sure to call the older variant that does not support dxml when libvirtd it talks to is not new enough and the did not explicitly set dxml to something non-null. That is, I think these particular changes to replace migration APIs with their *2 variants do not break backward compatibility.
There may be more patches like this in your series, but in general, you should favor forwarding calls to the older API, not the newer API, so that the clients will work against as many libvirt versions as possible.
OK, this makes sense. But where do we draw the line?
We do not draw lines in libvirt :-) Something that used to work should not just stop working when you upgrade your libvirt library or a binding. Jirka

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/StorageVol.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/libvirt/StorageVol.java b/src/main/java/org/libvirt/StorageVol.java index 66e647f..9ea23c7 100644 --- a/src/main/java/org/libvirt/StorageVol.java +++ b/src/main/java/org/libvirt/StorageVol.java @@ -23,6 +23,13 @@ public class StorageVol { static final int VIR_STORAGE_POOL_DELETE_ZEROED = 1; } + static final class ResizeFlags { + /** + * Size is in bytes instead of KiB + */ + static final int VIR_DOMAIN_BLOCK_RESIZE_BYTES = (1 << 0); + } + public static enum Type { /** * Regular file based volumes -- 1.7.9.5

At Sat, 5 Jan 2013 12:48:26 +0100, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/StorageVol.java | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/src/main/java/org/libvirt/StorageVol.java b/src/main/java/org/libvirt/StorageVol.java index 66e647f..9ea23c7 100644 --- a/src/main/java/org/libvirt/StorageVol.java +++ b/src/main/java/org/libvirt/StorageVol.java @@ -23,6 +23,13 @@ public class StorageVol { static final int VIR_STORAGE_POOL_DELETE_ZEROED = 1; }
+ static final class ResizeFlags { + /** + * Size is in bytes instead of KiB + */ + static final int VIR_DOMAIN_BLOCK_RESIZE_BYTES = (1 << 0); + } + public static enum Type { /**
NACK. According to the libvirt API, virStorageVolResizeFlags has these possible values: VIR_STORAGE_VOL_RESIZE_ALLOCATE = 1 : force allocation of new size VIR_STORAGE_VOL_RESIZE_DELTA = 2 : size is relative to current VIR_STORAGE_VOL_RESIZE_SHRINK = 4 : allow decrease in capacity You probably want to move the stanza above into Domain.java. Please rename the class when you do this to "BlockResizeFlags" to be consistant with the naming in libvirt. Additionally, consensus was that we should drop the C prefixes from enum values when wrapping them in Java. I will do this for existing enums when I find the time, but for new enums we could just as well avoid introducing them in the first place. In this case the prefix of VIR_DOMAIN_BLOCK_RESIZE should be removed. Usage would thus be Domain.BlockResizeFlags.BYTES instead of the repetitious Domain.BlockResizeFlags.VIR_DOMAIN_BLOCK_RESIZE_BYTES Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

On Mon, Jan 07, 2013 at 12:38:16 +0100, Claudio Bley wrote: ...
Additionally, consensus was that we should drop the C prefixes from enum values when wrapping them in Java. I will do this for existing enums when I find the time, but for new enums we could just as well avoid introducing them in the first place.
In this case the prefix of VIR_DOMAIN_BLOCK_RESIZE should be removed. Usage would thus be
Domain.BlockResizeFlags.BYTES
This is certainly good for new enums, however, you need to be careful when changing existing enums. You would need to keep the long names for backward compatibility. Jirka

At Mon, 7 Jan 2013 16:41:14 +0100, Jiri Denemark wrote:
On Mon, Jan 07, 2013 at 12:38:16 +0100, Claudio Bley wrote: ...
Additionally, consensus was that we should drop the C prefixes from enum values when wrapping them in Java. I will do this for existing enums when I find the time, but for new enums we could just as well avoid introducing them in the first place.
In this case the prefix of VIR_DOMAIN_BLOCK_RESIZE should be removed. Usage would thus be
Domain.BlockResizeFlags.BYTES
This is certainly good for new enums, however, you need to be careful when changing existing enums. You would need to keep the long names for backward compatibility.
This is certainly true. But there are some issues that require changing the API without being able to provide backward compatibility. (Changing method return types, without changing their parameter list, so overloading does not help here). The plan is to drop backward compatibility at some point and fix all of those issues. Probably in libvirt-java 0.5.x. Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
participants (4)
-
Claudio Bley
-
Eric Blake
-
Jiri Denemark
-
Wido den Hollander