public class Domain
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Domain.BlockResizeFlags |
static class |
Domain.SnapshotListFlags |
static class |
Domain.UndefineFlags |
| Modifier and Type | Method and Description |
|---|---|
int |
abortJob()
Requests that the current background job be aborted at the soonest
opportunity.
|
void |
attachDevice(java.lang.String xmlDesc)
Creates a virtual device attachment to backend.
|
void |
attachDeviceFlags(java.lang.String xmlDesc,
int flags)
Creates a virtual device attachment to backend.
|
DomainBlockInfo |
blockInfo(java.lang.String path)
This function returns block device (disk) stats for block devices
attached to the domain.
|
void |
blockResize(java.lang.String disk,
long size,
int flags)
Resize a block device of domain while the domain is running.
|
DomainBlockStats |
blockStats(java.lang.String path)
Returns block device (disk) stats for block devices attached to this
domain.
|
void |
coreDump(java.lang.String to,
int flags)
Dumps the core of this domain on a given file for analysis.
|
int |
cpuMapLength(int maxCpus)
It returns the length (in bytes) required to store the complete CPU map
between a single virtual & all physical CPUs of a domain.
|
int |
create()
Launches this defined domain.
|
int |
create(int flags)
Launches this defined domain with the provide flags.
|
void |
destroy()
Destroys this domain object.
|
void |
detachDevice(java.lang.String xmlDesc)
Destroys a virtual device attachment to backend.
|
void |
detachDeviceFlags(java.lang.String xmlDesc,
int flags)
Destroys a virtual device attachment to backend.
|
protected void |
finalize() |
int |
free()
Frees this domain object.
|
boolean |
getAutostart()
Provides a boolean value indicating whether the network is configured to
be automatically started when the host machine boots.
|
Connect |
getConnect()
Provides the connection object associated with a domain.
|
int |
getID()
Gets the hypervisor ID number for the domain
|
DomainInfo |
getInfo()
Extract information about a domain.
|
DomainJobInfo |
getJobInfo()
Extract information about progress of a background job on a domain.
|
long |
getMaxMemory()
Retrieve the maximum amount of physical memory allocated to a domain.
|
int |
getMaxVcpus()
Provides the maximum number of virtual CPUs supported for the guest VM.
|
java.lang.String |
getName()
Gets the public name for this domain
|
java.lang.String |
getOSType()
Gets the type of domain operation system.
|
SchedParameter[] |
getSchedulerParameters()
Gets the scheduler parameters.
|
java.lang.String[] |
getSchedulerType()
Gets the scheduler type.
|
int[] |
getUUID()
Get the UUID for this domain.
|
java.lang.String |
getUUIDString()
Gets the UUID for this domain as string.
|
int[] |
getVcpusCpuMaps()
Returns the cpumaps for this domain Only the lower 8 bits of each int in
the array contain information.
|
VcpuInfo[] |
getVcpusInfo()
Extracts information about virtual CPUs of this domain
|
java.lang.String |
getXMLDesc(int flags)
Provides an XML description of the domain.
|
int |
hasCurrentSnapshot()
Determine if the domain has a snapshot
|
int |
hasManagedSaveImage()
Determine if the domain has a managed save image
|
DomainInterfaceStats |
interfaceStats(java.lang.String path)
Returns network interface stats for interfaces attached to this domain.
|
int |
isActive()
Determine if the domain is currently running
|
int |
isPersistent()
Determine if the domain has a persistent configuration which means it
will still exist after shutting down
|
int |
managedSave()
suspend a domain and save its memory contents to a file on disk.
|
int |
managedSaveRemove()
Remove any managed save images from the domain
|
MemoryStatistic[] |
memoryStats(int number)
This function provides memory statistics for the domain.
|
Domain |
migrate(Connect dconn,
long flags,
java.lang.String dname,
java.lang.String uri,
long bandwidth)
Migrate this domain object from its current host to the destination host
given by dconn (a connection to the destination host).
|
Domain |
migrate(Connect dconn,
long flags,
java.lang.String dxml,
java.lang.String dname,
java.lang.String uri,
long bandwidth)
Migrate this domain object from its current host to the destination host
given by dconn (a connection to the destination host).
|
int |
migrateSetMaxDowntime(long downtime)
Sets maximum tolerable time for which the domain is allowed to be paused
at the end of live migration.
|
int |
migrateToURI(java.lang.String uri,
long flags,
java.lang.String dname,
long bandwidth)
Migrate the domain object from its current host to the destination host
given by duri.
|
int |
migrateToURI(java.lang.String dconnuri,
java.lang.String miguri,
java.lang.String dxml,
long flags,
java.lang.String dname,
long bandwidth)
Migrate the domain object from its current host to the destination
denoted by a given URI.
|
void |
pinVcpu(int vcpu,
int[] cpumap)
Dynamically changes the real CPUs which can be allocated to a virtual
CPU.
|
protected void |
processError()
Error handling logic to throw errors.
|
void |
reboot(int flags)
Reboot this domain, the domain object is still usable there after but the
domain OS is being stopped for a restart.
|
void |
resume()
Resume this suspended domain, the process is restarted from the state
where it was frozen by calling virSuspendDomain().
|
int |
revertToSnapshot(DomainSnapshot snapshot)
Revert the domain to a given snapshot.
|
void |
save(java.lang.String to)
Suspends this domain and saves its memory contents to a file on disk.
|
void |
setAutostart(boolean autostart)
Configures the network to be automatically started when the host machine
boots.
|
void |
setMaxMemory(long memory)
* Dynamically change the maximum amount of physical memory allocated to a
domain.
|
void |
setMemory(long memory)
Dynamically changes the target amount of physical memory allocated to
this domain.
|
void |
setSchedulerParameters(SchedParameter[] params)
Changes the scheduler parameters
|
void |
setVcpus(int nvcpus)
Dynamically changes the number of virtual CPUs used by this domain.
|
void |
shutdown()
Shuts down this domain, the domain object is still usable there after but
the domain OS is being stopped.
|
DomainSnapshot |
snapshotCreateXML(java.lang.String xmlDesc)
Creates a new snapshot of a domain based on the snapshot xml contained in
xmlDesc.
|
DomainSnapshot |
snapshotCreateXML(java.lang.String xmlDesc,
int flags)
Creates a new snapshot of a domain based on the snapshot xml contained in
xmlDesc.
|
DomainSnapshot |
snapshotCurrent()
Get the current snapshot for a domain, if any.
|
java.lang.String[] |
snapshotListNames()
Collect the list of domain snapshots for the given domain.
|
java.lang.String[] |
snapshotListNames(int flags)
Collect the list of domain snapshots for the given domain.
|
DomainSnapshot |
snapshotLookupByName(java.lang.String name)
Retrieve a snapshot by name
|
int |
snapshotNum()
Provides the number of domain snapshots for this domain..
|
void |
suspend()
Suspends this active domain, the process is frozen without further access
to CPU resources and I/O but the memory used by the domain at the
hypervisor level will stay allocated.
|
void |
undefine()
undefines this domain but does not stop it if it is running
|
void |
undefine(int flags)
Undefines this domain but does not stop if it it is running.
|
int |
updateDeviceFlags(java.lang.String xml,
int flags)
Change a virtual device on a domain
|
public int abortJob()
throws LibvirtException
LibvirtExceptionpublic void attachDevice(java.lang.String xmlDesc)
throws LibvirtException
xmlDesc - XML description of one deviceLibvirtExceptionpublic void attachDeviceFlags(java.lang.String xmlDesc,
int flags)
throws LibvirtException
xmlDesc - XML description of one deviceflags - the an OR'ed set of virDomainDeviceModifyFlagsLibvirtExceptionpublic DomainBlockInfo blockInfo(java.lang.String path) throws LibvirtException
path - the path to the block deviceLibvirtExceptionpublic DomainBlockStats blockStats(java.lang.String path) throws LibvirtException
path - path to the block deviceLibvirtExceptionpublic void blockResize(java.lang.String disk,
long size,
int flags)
throws LibvirtException
disk - path to the block image, or shorthand (like vda)size - the new size of the block devicesflags - bitwise OR'ed values of Domain.BlockResizeFlagsLibvirtExceptionpublic void coreDump(java.lang.String to,
int flags)
throws LibvirtException
to - path for the core fileflags - extra flags, currently unusedLibvirtExceptionpublic int cpuMapLength(int maxCpus)
public int create()
throws LibvirtException
LibvirtExceptionpublic int create(int flags)
throws LibvirtException
LibvirtExceptionpublic void destroy()
throws LibvirtException
LibvirtExceptionpublic void detachDevice(java.lang.String xmlDesc)
throws LibvirtException
xmlDesc - XML description of one deviceLibvirtExceptionpublic void detachDeviceFlags(java.lang.String xmlDesc,
int flags)
throws LibvirtException
xmlDesc - XML description of one deviceLibvirtExceptionprotected void finalize()
throws LibvirtException
finalize in class java.lang.ObjectLibvirtExceptionpublic int free()
throws LibvirtException
LibvirtExceptionpublic boolean getAutostart()
throws LibvirtException
LibvirtExceptionpublic Connect getConnect()
public int getID()
throws LibvirtException
LibvirtExceptionpublic DomainInfo getInfo() throws LibvirtException
LibvirtExceptionpublic DomainJobInfo getJobInfo() throws LibvirtException
LibvirtExceptionpublic long getMaxMemory()
throws LibvirtException
LibvirtExceptionpublic int getMaxVcpus()
throws LibvirtException
LibvirtExceptionpublic java.lang.String getName()
throws LibvirtException
LibvirtExceptionpublic java.lang.String getOSType()
throws LibvirtException
LibvirtExceptionpublic SchedParameter[] getSchedulerParameters() throws LibvirtException
LibvirtExceptionpublic java.lang.String[] getSchedulerType()
throws LibvirtException
LibvirtExceptionpublic int[] getUUID()
throws LibvirtException
LibvirtExceptionpublic java.lang.String getUUIDString()
throws LibvirtException
LibvirtExceptionpublic int[] getVcpusCpuMaps()
throws LibvirtException
LibvirtExceptionpublic VcpuInfo[] getVcpusInfo() throws LibvirtException
LibvirtExceptionpublic java.lang.String getXMLDesc(int flags)
throws LibvirtException
flags - not usedLibvirtExceptionpublic int hasCurrentSnapshot()
throws LibvirtException
LibvirtExceptionpublic int hasManagedSaveImage()
throws LibvirtException
LibvirtExceptionpublic DomainInterfaceStats interfaceStats(java.lang.String path) throws LibvirtException
path - path to the interfaceLibvirtExceptionpublic int isActive()
throws LibvirtException
LibvirtExceptionpublic int isPersistent()
throws LibvirtException
LibvirtExceptionpublic int managedSave()
throws LibvirtException
LibvirtExceptionpublic int managedSaveRemove()
throws LibvirtException
LibvirtExceptionpublic MemoryStatistic[] memoryStats(int number) throws LibvirtException
number - the number of stats to retrieveLibvirtExceptionpublic Domain migrate(Connect dconn, long flags, java.lang.String dxml, java.lang.String dname, java.lang.String uri, long bandwidth) throws LibvirtException
Flags may be bitwise OR'ed values of
MigrateFlags.
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 exception.
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.
The maximum bandwidth (in Mbps) that will be used to do migration can be specified with the bandwidth parameter. 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.
dconn - destination host (a Connect object)dxml - (optional) XML config for launching guest on targetflags - flagsdname - (optional) rename domain to this at destinationuri - (optional) dest hostname/URI as seen from the source hostbandwidth - (optional) specify migration bandwidth limit in MbpsLibvirtException - if the migration failspublic Domain migrate(Connect dconn, long flags, java.lang.String dname, java.lang.String uri, long bandwidth) throws LibvirtException
dconn - destination host (a Connect object)flags - flagsdname - (optional) rename domain to this at destinationuri - (optional) dest hostname/URI as seen from the source hostbandwidth - optional) specify migration bandwidth limit in MbpsLibvirtExceptionpublic int migrateSetMaxDowntime(long downtime)
throws LibvirtException
downtime - the time to be downLibvirtExceptionpublic int migrateToURI(java.lang.String dconnuri,
java.lang.String miguri,
java.lang.String dxml,
long flags,
java.lang.String dname,
long bandwidth)
throws LibvirtException
The destination is given either in dconnuri (if the
PEER2PEER
is flag set), or in miguri (if neither the
PEER2PEER nor the
TUNNELLED migration
flag is set in flags).
dconnuri - (optional) URI for target libvirtd if @flags includes VIR_MIGRATE_PEER2PEERmiguri - (optional) URI for invoking the migration, not if @flags includs VIR_MIGRATE_TUNNELLEDdxml - (optional) XML config for launching guest on targetflags - Controls the migratedname - The name at the destnationbandwidth - Specify the migration bandwidthLibvirtExceptionpublic int migrateToURI(java.lang.String uri,
long flags,
java.lang.String dname,
long bandwidth)
throws LibvirtException
uri - The destination URIflags - Controls the migratedname - The name at the destnationbandwidth - Specify the migration bandwidthLibvirtExceptionpublic void pinVcpu(int vcpu,
int[] cpumap)
throws LibvirtException
vcpu - virtual cpu numbercpumap - bit map of real CPUs represented by the the lower 8 bits of
each int in the array. Each bit set to 1 means that
corresponding CPU is usable. Bytes are stored in little-endian
order: CPU0-7, 8-15... In each byte, lowest CPU number is
least significant bit.LibvirtExceptionprotected void processError()
throws LibvirtException
LibvirtExceptionpublic void reboot(int flags)
throws LibvirtException
flags - extra flags for the reboot operation, not used yetLibvirtExceptionpublic void resume()
throws LibvirtException
LibvirtExceptionpublic int revertToSnapshot(DomainSnapshot snapshot) throws LibvirtException
snapshot - the snapshot to revert toLibvirtExceptionpublic void save(java.lang.String to)
throws LibvirtException
to - path for the output fileLibvirtExceptionpublic void setAutostart(boolean autostart)
throws LibvirtException
autostart - LibvirtExceptionpublic void setMaxMemory(long memory)
throws LibvirtException
memory - the amount memory in kilobytesLibvirtExceptionpublic void setMemory(long memory)
throws LibvirtException
memory - in kilobytesLibvirtExceptionpublic void setSchedulerParameters(SchedParameter[] params) throws LibvirtException
params - an array of SchedParameter objects to be changedLibvirtExceptionpublic void setVcpus(int nvcpus)
throws LibvirtException
nvcpus - the new number of virtual CPUs for this domainLibvirtExceptionpublic void shutdown()
throws LibvirtException
LibvirtExceptionpublic DomainSnapshot snapshotCreateXML(java.lang.String xmlDesc, int flags) throws LibvirtException
xmlDesc - string containing an XML description of the domainflags - flags for creating the snapshot, see the virDomainSnapshotCreateFlags for the flag optionsLibvirtExceptionpublic DomainSnapshot snapshotCreateXML(java.lang.String xmlDesc) throws LibvirtException
This is just a convenience method, it has the same effect
as calling snapshotCreateXML(xmlDesc, 0);.
xmlDesc - string containing an XML description of the domainLibvirtException#snapshotCreateXML(int),
Libvirt
Documentationpublic DomainSnapshot snapshotCurrent() throws LibvirtException
LibvirtExceptionpublic java.lang.String[] snapshotListNames(int flags)
throws LibvirtException
LibvirtExceptionpublic java.lang.String[] snapshotListNames()
throws LibvirtException
This is just a convenience method, it has the same effect
as calling snapshotListNames(0);.
LibvirtExceptionsnapshotListNames(int),
virDomainSnapshotListNamespublic DomainSnapshot snapshotLookupByName(java.lang.String name) throws LibvirtException
name - the nameLibvirtExceptionpublic int snapshotNum()
throws LibvirtException
LibvirtExceptionpublic void suspend()
throws LibvirtException
LibvirtExceptionpublic void undefine()
throws LibvirtException
LibvirtExceptionpublic void undefine(int flags)
throws LibvirtException
flags - flags for undefining the domain. See virDomainUndefineFlagsValues for more informationLibvirtExceptionpublic int updateDeviceFlags(java.lang.String xml,
int flags)
throws LibvirtException
xml - the xml to update withflags - controls the updateLibvirtException