[PATCH libvirt-java 6/7] Implement virDomainMigrate2 and use it for a new migrate method.

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

 



virDomainMigrate2 adds the dxml argument which makes it possible
to alter host-specific portions of the domain XML that will be
used on the destination host.

The original migrate method still uses virDomainMigrate for backwards
compatibility reasons.

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

diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index 6bdc1df..2758747 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -778,6 +778,64 @@ public class Domain {
 
     /**
      * 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 tofind 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.
+     *
+     * If the hypervisor supports it, @dxml can be used to alter
+     * host-specific portions of the domain XML that will be used on
+     * the destination.
+     *
+     * @param dconn
+     *            destination host (a Connect object)
+     * @param dxml
+     *            (optional) XML config for launching guest on target
+     * @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 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,
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index b814cab..4a8bdf3 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -221,6 +221,8 @@ public interface Libvirt extends Library {
     int virDomainManagedSaveRemove(DomainPointer virDomainPtr, int flags);
     DomainPointer virDomainMigrate(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr,
             NativeLong flags, String dname, String uri, NativeLong bandwidth);
+    DomainPointer virDomainMigrate2(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr,
+            String dxml, NativeLong flags, String dname, String uri, NativeLong bandwidth);
     int virDomainMigrateSetMaxDowntime(DomainPointer virDomainPtr, long downtime, int flags);
     int virDomainMigrateToURI(DomainPointer virDomainPtr, String duri,
             NativeLong flags, String dname, NativeLong bandwidth);
-- 
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]