Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: New features #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

<name>libvirt java bindings</name>
<description>Java API for the libvirt C library</description>
<url>http://www.libvirt.org</url>
<url>https://www.libvirt.org</url>

<licenses>
<license>
<name>MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<url>https://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>

Expand Down Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.2</version>
</dependency>
</dependencies>

Expand Down
376 changes: 262 additions & 114 deletions src/main/java/org/libvirt/Domain.java

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/main/java/org/libvirt/jna/Libvirt.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
import org.libvirt.jna.callbacks.VirConnectCloseFunc;
import org.libvirt.jna.callbacks.VirDomainEventCallback;
import org.libvirt.jna.callbacks.VirErrorCallback;
Expand Down Expand Up @@ -132,6 +133,8 @@ public interface Libvirt extends Library {

DomainPointer virDomainMigrate2(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr, String dxml, NativeLong flags, String dname, String uri, NativeLong bandwidth);

DomainPointer virDomainMigrate3(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr, virTypedParameter[] params, int nparams, NativeLong flags);

DomainSnapshotPointer virDomainSnapshotCreateXML(DomainPointer virDomainPtr, String xmlDesc, int flags);

DomainSnapshotPointer virDomainSnapshotCurrent(DomainPointer virDomainPtr, int flags);
Expand Down Expand Up @@ -248,6 +251,8 @@ public interface Libvirt extends Library {

int virDomainGetJobInfo(DomainPointer virDomainPtr, virDomainJobInfo vInfo);

int virDomainGetJobStats(DomainPointer virDomainPtr, IntByReference type, PointerByReference params, IntByReference nparams, int flags);

int virDomainGetMaxVcpus(DomainPointer virDomainPtr);

int virDomainGetSchedulerParameters(DomainPointer virDomainPtr, virTypedParameter[] params, IntByReference nparams);
Expand Down Expand Up @@ -286,6 +291,8 @@ public interface Libvirt extends Library {

int virDomainMigrateToURI2(DomainPointer virDomainPtr, String dconnuri, String miguri, String dxml, NativeLong flags, String dname, NativeLong bandwidth);

int virDomainMigrateToURI3(DomainPointer virDomainPtr, String dconnuri, virTypedParameter[] params, int nparams, NativeLong flags);

int virDomainPinVcpu(DomainPointer virDomainPtr, int vcpu, byte[] cpumap, int maplen);

int virDomainPMSuspendForDuration(DomainPointer virDomainPtr, int target, long duration, int flags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.List;

import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import org.libvirt.jna.Libvirt;

Expand All @@ -16,6 +17,14 @@ public class virTypedParameter extends Structure {

private static final List<String> fields = Arrays.asList("field", "type", "value");

public virTypedParameter() {
super();
}

public virTypedParameter(Pointer p) {
super(p);
}

@Override
protected List<String> getFieldOrder() {
return fields;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.libvirt.jna.structures;

import com.sun.jna.Pointer;
import com.sun.jna.Union;

/**
Expand All @@ -11,4 +12,5 @@ public class virTypedParameterValue extends Union {
public double d; /* data for double case */
public byte b; /* data for char case */
public String s; /* data for string case */
public Pointer p;
}
270 changes: 270 additions & 0 deletions src/main/java/org/libvirt/parameters/DomainMigrateParameters.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
package org.libvirt.parameters;

public class DomainMigrateParameters {
/**
* VIR_MIGRATE_PARAM_URI:
*
* virDomainMigrate* params field: URI to use for initiating domain migration
* as VIR_TYPED_PARAM_STRING. It takes a hypervisor specific format. The
* uri_transports element of the hypervisor capabilities XML includes details
* of the supported URI schemes. When omitted libvirt will auto-generate
* suitable default URI. It is typically only necessary to specify this URI if
* the destination host has multiple interfaces and a specific interface is
* required to transmit migration data.
*
* This field may not be used when VIR_MIGRATE_TUNNELLED flag is set.
*
* Since: 1.1.0
*/
public static final String VIR_MIGRATE_PARAM_URI = "migrate_uri";

/**
* VIR_MIGRATE_PARAM_DEST_NAME:
*
* virDomainMigrate* params field: the name to be used for the domain on the
* destination host as VIR_TYPED_PARAM_STRING. Omitting this parameter keeps
* the domain name the same. This field is only allowed to be used with
* hypervisors that support domain renaming during migration.
*
* Since: 1.1.0
*/
public static final String VIR_MIGRATE_PARAM_DEST_NAME = "destination_name";

/**
* VIR_MIGRATE_PARAM_DEST_XML:
*
* virDomainMigrate* params field: the new configuration to be used for the
* domain on the destination host as VIR_TYPED_PARAM_STRING. The configuration
* must include an identical set of virtual devices, to ensure a stable guest
* ABI across migration. Only parameters related to host side configuration
* can be changed in the XML. Hypervisors which support this field will forbid
* migration if the provided XML would cause a change in the guest ABI. This
* field cannot be used to rename the domain during migration (use
* VIR_MIGRATE_PARAM_DEST_NAME field for that purpose). Domain name in the
* destination XML must match the original domain name.
*
* Omitting this parameter keeps the original domain configuration. Using this
* field with hypervisors that do not support changing domain configuration
* during migration will result in a failure.
*
* Since: 1.1.0
*/
public static final String VIR_MIGRATE_PARAM_DEST_XML = "destination_xml";

/**
* VIR_MIGRATE_PARAM_PERSIST_XML:
*
* virDomainMigrate* params field: the new persistent configuration to be used
* for the domain on the destination host as VIR_TYPED_PARAM_STRING.
* This field cannot be used to rename the domain during migration (use
* VIR_MIGRATE_PARAM_DEST_NAME field for that purpose). Domain name in the
* destination XML must match the original domain name.
*
* Omitting this parameter keeps the original domain persistent configuration.
* Using this field with hypervisors that do not support changing domain
* configuration during migration will result in a failure.
*
* Since: 1.3.4
*/
public static final String VIR_MIGRATE_PARAM_PERSIST_XML = "persistent_xml";

/**
* VIR_MIGRATE_PARAM_BANDWIDTH:
*
* virDomainMigrate* params field: the maximum bandwidth (in MiB/s) that will
* be used for migration as VIR_TYPED_PARAM_ULLONG. If set to 0 or omitted,
* libvirt will choose a suitable default. Some hypervisors do not support this
* feature and will return an error if this field is used and is not 0.
*
* Since: 1.1.0
*/
public static final String VIR_MIGRATE_PARAM_BANDWIDTH = "bandwidth";

/**
* VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY:
*
* virDomainMigrate* params field: the maximum bandwidth (in MiB/s) that will
* be used for post-copy phase of a migration as VIR_TYPED_PARAM_ULLONG. If set
* to 0 or omitted, post-copy migration speed will not be limited.
*
* Since: 5.1.0
*/
public static final String VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY = "bandwidth.postcopy";

/**
* VIR_MIGRATE_PARAM_GRAPHICS_URI:
*
* virDomainMigrate* params field: URI to use for migrating client's connection
* to domain's graphical console as VIR_TYPED_PARAM_STRING. If specified, the
* client will be asked to automatically reconnect using these parameters
* instead of the automatically computed ones. This can be useful if, e.g., the
* client does not have a direct access to the network virtualization hosts are
* connected to and needs to connect through a proxy. The URI is formed as
* follows:
*
* protocol://hostname[:port]/[?parameters]
*
* where protocol is either "spice" or "vnc" and parameters is a list of
* protocol specific parameters separated by '&'. Currently recognized
* parameters are "tlsPort" and "tlsSubject". For example,
*
* spice://target.host.com:1234/?tlsPort=4567
*
* Since: 1.1.0
*/
public static final String VIR_MIGRATE_PARAM_GRAPHICS_URI = "graphics_uri";

/**
* VIR_MIGRATE_PARAM_LISTEN_ADDRESS:
*
* virDomainMigrate* params field: The listen address that hypervisor on the
* destination side should bind to for incoming migration. Both IPv4 and IPv6
* addresses are accepted as well as hostnames (the resolving is done on
* destination). Some hypervisors do not support this feature and will return
* an error if this field is used.
*
* Since: 1.1.4
*/
public static final String VIR_MIGRATE_PARAM_LISTEN_ADDRESS = "listen_address";

/**
* VIR_MIGRATE_PARAM_MIGRATE_DISKS:
*
* virDomainMigrate* params multiple field: The multiple values that list
* the block devices to be migrated. At the moment this is only supported
* by the QEMU driver but not for the tunnelled migration.
*
* Since: 1.2.17
*/
public static final String VIR_MIGRATE_PARAM_MIGRATE_DISKS = "migrate_disks";

/**
* VIR_MIGRATE_PARAM_DISKS_PORT:
*
* virDomainMigrate* params field: port that destination server should use
* for incoming disks migration. Type is VIR_TYPED_PARAM_INT. If set to 0 or
* omitted, libvirt will choose a suitable default. At the moment this is only
* supported by the QEMU driver.
*
* Since: 1.3.3
*/
public static final String VIR_MIGRATE_PARAM_DISKS_PORT = "disks_port";

/**
* VIR_MIGRATE_PARAM_DISKS_URI:
*
* virDomainMigrate* params field: URI used for incoming disks migration. Type
* is VIR_TYPED_PARAM_STRING. Only schemes "tcp" and "unix" are accepted. TCP
* URI can currently only provide a server and port to listen on (and connect
* to), UNIX URI may only provide a path component for a UNIX socket. This is
* currently only supported by the QEMU driver. UNIX URI is only usable if the
* management application makes sure that socket created with this name on the
* destination will be reachable from the source under the same exact path.
*
* Since: 6.8.0
*/
public static final String VIR_MIGRATE_PARAM_DISKS_URI = "disks_uri";

/**
* VIR_MIGRATE_PARAM_COMPRESSION:
*
* virDomainMigrate* params multiple field: name of the method used to
* compress migration traffic. Supported compression methods: xbzrle, mt.
* The parameter may be specified multiple times if more than one method
* should be used.
*
* Since: 1.3.4
*/
public static final String VIR_MIGRATE_PARAM_COMPRESSION = "compression";

/**
* VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL:
*
* virDomainMigrate* params field: the level of compression for multithread
* compression as VIR_TYPED_PARAM_INT. Accepted values are in range 0-9.
* 0 is no compression, 1 is maximum speed and 9 is maximum compression.
*
* Since: 1.3.4
*/
public static final String VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL = "compression.mt.level";

/**
* VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS:
*
* virDomainMigrate* params field: the number of compression threads for
* multithread compression as VIR_TYPED_PARAM_INT.
*
* Since: 1.3.4
*/
public static final String VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS = "compression.mt.threads";

/**
* VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS:
*
* virDomainMigrate* params field: the number of decompression threads for
* multithread compression as VIR_TYPED_PARAM_INT.
*
* Since: 1.3.4
*/
public static final String VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS = "compression.mt.dthreads";

/**
* VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE:
*
* virDomainMigrate* params field: the size of page cache for xbzrle
* compression as VIR_TYPED_PARAM_ULLONG.
*
* Since: 1.3.4
*/
public static final String VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE = "compression.xbzrle.cache";

/**
* VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL:
*
* virDomainMigrate* params field: the initial percentage guest CPUs are
* throttled to when auto-convergence decides migration is not converging.
* As VIR_TYPED_PARAM_INT.
*
* Since: 2.0.0
*/
public static final String VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL = "auto_converge.initial";

/**
* VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT:
*
* virDomainMigrate* params field: the increment added to
* VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL whenever the hypervisor decides
* the current rate is not enough to ensure convergence of the migration.
* As VIR_TYPED_PARAM_INT.
*
* Since: 2.0.0
*/
public static final String VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT = "auto_converge.increment";

/**
* VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS:
*
* virDomainMigrate* params field: number of connections used during parallel
* migration. As VIR_TYPED_PARAM_INT.
*
* Since: 5.2.0
*/
public static final String VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS = "parallel.connections";

/**
* VIR_MIGRATE_PARAM_TLS_DESTINATION:
*
* virDomainMigrate* params field: override the destination host name used for
* TLS verification. As VIR_TYPED_PARAM_STRING.
*
* Normally the TLS certificate from the destination host must match the host's
* name for TLS verification to succeed. When the certificate does not match
* the destination hostname and the expected certificate's hostname is known,
* this parameter can be used to pass this expected hostname when starting
* the migration.
*
* Since: 6.0.0
*/
public static final String VIR_MIGRATE_PARAM_TLS_DESTINATION = "tls.destination";

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
* Class for representing a boolean typed parameter
*/
public final class TypedBooleanParameter extends TypedParameter {
private boolean value;
public boolean value;

public TypedBooleanParameter() {
}

public TypedBooleanParameter(boolean value) {
this.value = value;
}

public TypedBooleanParameter(byte value) {
this.value = ((value) != 0);
}

public TypedBooleanParameter(boolean value, String field) {
this.setField(field);
this.setValue(value);
Expand Down
Loading