Sys::Virt::Domain(3) User Contributed Perl Documentation Sys::Virt::Domain(3)

Sys::Virt::Domain - Represent & manage a libvirt guest domain

The "Sys::Virt::Domain" module represents a guest domain managed by the virtual machine monitor.

Returns an integer with a locally unique identifier for the domain.
Returns a 16 byte long string containing the raw globally unique identifier (UUID) for the domain.
Returns a printable string representation of the raw UUID, in the format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'.
Returns a string with a locally unique name of the domain
Returns a string representing the hostname of the guest. $flags can be zero or more of
Report the guest agent hostname
Report the DHCP lease hostname
Returns the metadata element of type $type associated with the domain. If $type is "Sys::Virt::Domain::METADATA_ELEMENT" then the $uri parameter specifies the XML namespace to retrieve, otherwise $uri should be "undef". The optional $flags parameter defaults to zero.
$dom->set_metadata($type, $val, $key, $uri, $flags=0)
Sets the metadata element of type $type to hold the value $val. If $type is "Sys::Virt::Domain::METADATA_ELEMENT" then the $key and $uri elements specify an XML namespace to use, otherwise they should both be "undef". The optional $flags parameter defaults to zero.
$dom->is_active()
Returns a true value if the domain is currently running
$dom->is_persistent()
Returns a true value if the domain has a persistent configuration file defined
$dom->is_updated()
Returns a true value if the domain is running and has a persistent configuration file defined that is out of date compared to the current live config.
Returns an XML document containing a complete description of the domain's configuration. The optional $flags parameter controls generation of the XML document, defaulting to 0 if omitted. It can be one or more of the XML DUMP constants listed later in this document.
Returns a string containing the name of the OS type running within the domain.
$dom->create($flags)
Start a domain whose configuration was previously defined using the "define_domain" method in Sys::Virt. The $flags parameter accepts one of the DOMAIN CREATION constants documented later, and defaults to 0 if omitted.
$dom->create_with_files($fds, $flags)
Start a domain whose configuration was previously defined using the "define_domain" method in Sys::Virt. The $fds parameter is an array of UNIX file descriptors which will be passed to the init process of the container. This is only supported with container based virtualization.The $flags parameter accepts one of the DOMAIN CREATION constants documented later, and defaults to 0 if omitted.
$dom->undefine()
Remove the configuration associated with a domain previously defined with the "define_domain" method in Sys::Virt. If the domain is running, you probably want to use the "shutdown" or "destroy" methods instead.
$dom->suspend()
Temporarily stop execution of the domain, allowing later continuation by calling the "resume" method.
$dom->resume()
Resume execution of a domain previously halted with the "suspend" method.
$dom->pm_wakeup()
Wakeup the guest from power management suspend state
$dom->pm_suspend_for_duration($target, $duration, $flags=0)
Tells the guest OS to enter the power management suspend state identified by $target. The $target parameter should be one of the NODE SUSPEND CONTANTS listed in "Sys::Virt". The $duration specifies when the guest should automatically wakeup. The $flags parameter is optional and defaults to zero.
$dom->save($filename)
Take a snapshot of the domain's state and save the information to the file named in the $filename parameter. The domain can later be restored from this file with the "restore_domain" method on the Sys::Virt object.
$dom->managed_save($flags=0)
Take a snapshot of the domain's state and save the information to a managed save location. The domain will be automatically restored with this state when it is next started. The $flags parameter is unused and defaults to zero.
$bool = $dom->has_managed_save_image($flags=0)
Return a non-zero value if the domain has a managed save image that will be used at next start. The $flags parameter is unused and defaults to zero.
$dom->managed_save_remove($flags=0)
Remove the current managed save image, causing the guest to perform a full boot next time it is started. The $flags parameter is unused and defaults to zero.
$dom->managed_save_define_xml($xml, $flags=0)
Update the XML of the managed save image to $xml. The $flags parameter is unused and defaults to zero.
$xml = $dom->managed_save_get_xml_description($flags=0)
Get the XML in the managed save image. The $flags parameter accepts the following constants
Include security sensitive information in the XML dump, such as passwords.
$dom->core_dump($filename[, $flags])
Trigger a core dump of the guest virtual machine, saving its memory image to $filename so it can be analysed by tools such as "crash". The optional $flags flags parameter is currently unused and if omitted will default to 0.
$dom->core_dump_format($filename, $format, [, $flags])
Trigger a core dump of the guest virtual machine, saving its memory image to $filename so it can be analysed by tools such as "crash". The $format parameter is one of the core dump format constants. The optional $flags flags parameter is currently unused and if omitted will default to 0.
$dom->destroy()
Immediately poweroff the machine. This is equivalent to removing the power plug. The guest OS is given no time to cleanup / save state. For a clean poweroff sequence, use the "shutdown" method instead.
Returns a hash reference summarising the execution state of the domain. The elements of the hash are as follows:
The maximum memory allowed for this domain, in kilobytes
The current memory allocated to the domain in kilobytes
The amount of CPU time used by the domain
The current number of virtual CPUs enabled in the domain
The execution state of the machine, which will be one of the constants &Sys::Virt::Domain::STATE_*.
Returns an array whose values specify the current state of the guest, and the reason for it being in that state. The $state values are the same as for the "get_info" API, and the $reason values come from:
It is not known why the domain has crashed
The domain has crashed due to a kernel panic
It is not known why the domain has no state
The guest is paused due to a core dump operation
The guest is paused due to a snapshot
The guest is paused due to an I/O error
The guest is paused due to migration
The guest is paused due to a save operation
It is not known why the domain has paused
The guest is paused at admin request
The guest is paused due to the watchdog
The guest is paused while domain shutdown takes place
The guest is paused while a snapshot takes place
The guest is paused due to a kernel panic
The guest is paused as it is being started up.
The guest is paused as post-copy migration is taking place
The guest is paused as post-copy migration failed
The guest is running after being booted
The guest is running after restore from snapshot
The guest is running after migration
The guest is running after migration abort
The guest is running after restore from file
The guest is running after save cancel
It is not known why the domain has started
The guest is running after a resume
The guest is running after wakeup from power management suspend
The guest was restarted after crashing
The guest is running but post-copy is taking place
The guest is blocked for an unknown reason
It is not known why the domain has shutdown
The guest is shutdown due to admin request
The guest is shutoff after a crash
The guest is shutoff after being destroyed
The guest is shutoff due to a virtualization failure
The guest is shutoff after a snapshot
The guest is shutoff after migration
The guest is shutoff after a save
The guest is shutoff due to controlled shutdown
It is not known why the domain has shutoff
The daemon stopped the guest due to a failure
It is not known why the domain was suspended to RAM
It is not known why the domain was suspended to disk
Returns a hash reference providing information about the control channel. The returned keys in the hash are
"state"
One of the CONTROL INFO constants listed later
"details"
Currently unused, always 0.
"stateTime"
The elapsed time since the control channel entered the current state.
Get the current time of the guest, in seconds and nanoseconds. The $flags parameter is currently unused and defaults to zero. The return value is an array ref with two elements, the first contains the time in seconds, the second contains the remaining nanoseconds.
$dom->set_time($secs, $nsecs, $flags=0);
Set the current time of the guest, in seconds and nanoseconds. The $flags parameter accepts one of
"Sys::Virt::Domain::TIME_SYNC"
Re-sync domain time from domain's RTC.
$dom->set_user_password($username, $password, $flags=0);
Update the password for account $username to be $password. $password is the clear-text password string unless the PASSWORD_ENCRYPTED flag is set.
"Sys::Virt::Domain::PASSWORD_ENCRYPTED"
The $password is encrypted with the password scheme required by the guest OS.
$dom->rename($newname, $flags=0)
Change the name of an inactive guest to be $newname. The $flags parameter is currently unused and defaults to zero.
Returns a list of all disk errors that have occurred on the backing store for the guest's virtual disks. The returned array elements are hash references, containing two keys
"path"
The path of the disk with an error
"error"
The error type
$dom->send_key($keycodeset, $holdtime, \@keycodes, $flags=0)
Sends a sequence of keycodes to the guest domain. The $keycodeset should be one of the constants listed later in the KEYCODE SET section. $holdtiem is the duration, in milliseconds, to keep the key pressed before releasing it and sending the next keycode. @keycodes is an array reference containing the list of keycodes to send to the guest. The elements in the array should be keycode values from the specified keycode set. $flags is currently unused.
Returns a hash reference summarising the disk usage of the host backing store for a guest block device. The $dev parameter should be the path to the backing store on the host. $flags is currently unused and defaults to 0 if omitted. The returned hash contains the following elements
Logical size in bytes of the block device backing image *
Highest allocated extent in bytes of the block device backing image
Physical size in bytes of the container of the backing image
$dom->set_max_memory($mem)
Set the maximum memory for the domain to the value $mem. The value of the $mem parameter is specified in kilobytes.
$mem = $dom->get_max_memory()
Returns the current maximum memory allowed for this domain in kilobytes.
$dom->set_memory($mem, $flags)
Set the current memory for the domain to the value $mem. The value of the $mem parameter is specified in kilobytes. This must be less than, or equal to the domain's max memory limit. The $flags parameter can control whether the update affects the live guest, or inactive config, defaulting to modifying the current state.
$dom->set_memory_stats_period($period, $flags)
Set the period on which guests memory stats are refreshed, with $period being a value in seconds. The $flags parameter is currently unused.
$dom->shutdown()
Request that the guest OS perform a graceful shutdown and poweroff. This usually requires some form of cooperation from the guest operating system, such as responding to an ACPI signal, or a guest agent process. For an immediate, forceful poweroff, use the "destroy" method instead.
$dom->reboot([$flags])
Request that the guest OS perform a graceful shutdown and optionally restart. The optional $flags parameter is currently unused and if omitted defaults to zero.
$dom->reset([$flags])
Perform a hardware reset of the virtual machine. The guest OS is given no opportunity to shutdown gracefully. The optional $flags parameter is currently unused and if omitted defaults to zero.
$dom->get_max_vcpus()
Return the maximum number of vcpus that are configured for the domain
$dom->attach_device($xml[, $flags])
Hotplug a new device whose configuration is given by $xml, to the running guest. The optional <$flags> parameter defaults to 0, but can accept one of the device hotplug flags described later.
$dom->detach_device($xml[, $flags])
Hotunplug an existing device whose configuration is given by $xml, from the running guest. The optional <$flags> parameter defaults to 0, but can accept one of the device hotplug flags described later.
$dom->detach_device_alias($alias[, $flags])
Hotunplug an existing device which is identified by $alias. The optional <$flags> parameter defaults to 0, but can accept one of the device hotplug flags described later.
$dom->update_device($xml[, $flags])
Update the configuration of an existing device. The new configuration is given by $xml. The optional <$flags> parameter defaults to 0 but can accept one of the device hotplug flags described later.
$data = $dom->block_peek($path, $offset, $size[, $flags])
Peek into the guest disk $path, at byte $offset capturing $size bytes of data. The returned scalar may contain embedded NULLs. The optional $flags parameter is currently unused and if omitted defaults to zero.
$data = $dom->memory_peek($offset, $size[, $flags])
Peek into the guest memory at byte $offset virtual address, capturing $size bytes of memory. The return scalar may contain embedded NULLs. The optional $flags parameter is currently unused and if omitted defaults to zero.
$flag = $dom->get_autostart();
Return a true value if the guest domain is configured to automatically start upon boot. Return false, otherwise
$dom->set_autostart($flag)
Set the state of the autostart flag, which determines whether the guest will automatically start upon boot of the host OS
$dom->set_vcpus($count, [$flags])
Set the number of virtual CPUs in the guest VM to $count. The optional $flags parameter can be used to control whether the setting changes the live config or inactive config.
$dom->set_vcpu($cpumap, $state, [$flags])
Set the state of the CPUs in $cpumap to $state. The $flags parameter defaults to zero if not present.
$count = $dom->get_vcpus([$flags])
Get the number of virtual CPUs in the guest VM. The optional $flags parameter can be used to control whether to query the setting of the live config or inactive config.
$dom->set_guest_vcpus($cpumap, $state, [$flags=0])
Set the online status of the guest OS CPUs. The $cpumap parameter describes the set of CPUs to modify (eg "0-3,^1"). $state is either 1 to set the CPUs online, or 0 to set them offline. The $flags parameter is currently unused and defaults to 0.
$info $dom->get_guest_vcpus([$flags=0])
Query information about the guest OS CPUs. The returned data is a hash reference with the following keys.
String containing bitmap representing CPU ids reported currently known to the guest.
String containing bitmap representing CPU ids that are currently online in the guest.
String containing bitmap representing CPU ids that can be offlined in the guest.

The $flags parameter is currently unused and defaults to 0.

$type = $dom->get_scheduler_type()
Return the scheduler type for the guest domain
$stats = $dom->block_stats($path)
Fetch the current I/O statistics for the block device given by $path. The returned hash reference contains keys for
"rd_req"
Number of read requests
"rd_bytes"
Number of bytes read
"wr_req"
Number of write requests
"wr_bytes"
Number of bytes written
"errs"
Some kind of error count
Return the set of scheduler tunable parameters for the guest, as a hash reference. The precise set of keys in the hash are specific to the hypervisor.
$dom->set_scheduler_parameters($params, $flags=0)
Update the set of scheduler tunable parameters. The value names for tunables vary, and can be discovered using the "get_scheduler_params" call
Return a hash reference containing the set of memory tunable parameters for the guest. The keys in the hash are one of the constants MEMORY PARAMETERS described later. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
$dom->set_memory_parameters($params, $flags=0)
Update the memory tunable parameters for the guest. The $params should be a hash reference whose keys are one of the MEMORY PARAMETERS constants. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
Return a hash reference containing the set of blkio tunable parameters for the guest. The keys in the hash are one of the constants BLKIO PARAMETERS described later. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
$dom->set_blkio_parameters($params, $flags=0)
Update the blkio tunable parameters for the guest. The $params should be a hash reference whose keys are one of the BLKIO PARAMETERS constants. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
$stats = $dom->get_block_iotune($disk, $flags=0)
Return a hash reference containing the set of blkio tunable parameters for the guest disk $disk. The keys in the hash are one of the constants BLOCK IOTUNE PARAMETERS described later.
$dom->set_block_iotune($disk, $params, $flags=0);
Update the blkio tunable parameters for the guest disk $disk. The $params should be a hash reference whose keys are one of the BLOCK IOTUNE PARAMETERS constants.
Return a hash reference containing the set of interface tunable parameters for the guest. The keys in the hash are one of the constants INTERFACE PARAMETERS described later.
$dom->set_interface_parameters($intf, $params, $flags=0)
Update the interface tunable parameters for the guest. The $params should be a hash reference whose keys are one of the INTERFACE PARAMETERS constants.
Return a hash reference containing the set of numa tunable parameters for the guest. The keys in the hash are one of the constants NUMA PARAMETERS described later. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
$dom->set_numa_parameters($params, $flags=0)
Update the numa tunable parameters for the guest. The $params should be a hash reference whose keys are one of the NUMA PARAMETERS constants. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
Return a hash reference containing the set of performance events that are available for the guest. The keys in the hash are one of the constants PERF EVENTS described later. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
$dom->set_perf_events($params, $flags=0)
Update the enabled state for performance events for the guest. The $params should be a hash reference whose keys are one of the PERF EVENTS constants. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
$dom->block_resize($disk, $newsize, $flags=0)
Resize the disk $disk to have new size $newsize KB. If the disk is backed by a special image format, the actual resize is done by the hypervisor. If the disk is backed by a raw file, or block device, the resize must be done prior to invoking this API call, and it merely updates the hypervisor's view of the disk size. The following flags may be used
Treat $newsize as if it were in bytes, rather than KB.
$dom->interface_stats($path)
Fetch the current I/O statistics for the block device given by $path. The returned hash containins keys for
"rx_bytes"
Total bytes received
"rx_packets"
Total packets received
"rx_errs"
Total packets received with errors
"rx_drop"
Total packets drop at reception
"tx_bytes"
Total bytes transmitted
"tx_packets"
Total packets transmitted
"tx_errs"
Total packets transmitted with errors
"tx_drop"
Total packets dropped at transmission.
$dom->memory_stats($flags=0)
Fetch the current memory statistics for the guest domain. The $flags parameter is currently unused and can be omitted. The returned hash containins keys for
"swap_in"
Data read from swap space
"swap_out"
Data written to swap space
"major_fault"
Page fault involving disk I/O
"minor_fault"
Page fault not involving disk I/O
"unused"
Memory not used by the system
"available"
Total memory seen by guest
"rss"
Resident set size. Size of memory resident in host RAM.
$info = $dom->get_security_label()
Fetch information about the security label assigned to the guest domain. The returned hash reference has two keys, "model" gives the name of the security model in effect (eg "selinux"), while "label" provides the name of the security label applied to the domain. This method only returns information about the first security label. To retrieve all labels, use "get_security_label_list".
@info = $dom->get_security_label_list()
Fetches information about all security labels assigned to the guest domain. The elements in the returned array are all hash references, whose keys are as described for "get_security_label".
$ddom = $dom->migrate(destcon, \%params, flags=0)
Migrate a domain to an alternative host. The "destcon" parameter should be a "Sys::Virt" connection to the remote target host. The "flags" parameter takes one or more of the "Sys::Virt::Domain::MIGRATE_XXX" constants described later in this document. The %params parameter is a hash reference used to set various parameters for the migration operation, with the following valid keys.
"Sys::Virt::Domain::MIGRATE_PARAM_URI"
The URI to use for initializing the domain migration. 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.
"Sys::Virt::Domain::MIGRATE_PARAM_DEST_NAME"
The name to be used for the domain on the destination host. 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.
"Sys::Virt::Domain::MIGRATE_PARAM_DEST_XML"
The new configuration to be used for the domain on the destination host. 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.

"Sys::Virt::Domain::MIGRATE_PARAM_GRAPHICS_URI"
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
"Sys::Virt::Domain::MIGRATE_PARAM_BANDWIDTH"
The maximum bandwidth (in MiB/s) that will be used for migration. 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.
"Sys::Virt::Domain::MIGRATE_PARAM_BANDWIDTH_POSTCOPY"
The maximum bandwidth (in MiB/s) that will be used for migration during post-copy phase. If set to 0 or omitted, libvirt will choose a suitable default. Some hypervisors do not support this feature and return an error if this field is used and is not 0.
"Sys::Virt::Domain::MIGRATE_PARAM_LISTEN_ADDRESS"
The address on which to listen for incoming migration connections. If omitted, libvirt will listen on the wildcard address (0.0.0.0 or ::). This default may be a security risk if guests, or other untrusted users have the ability to connect to the virtualization host, thus use of an explicit restricted listen address is recommended.
"Sys::Virt::Domain::MIGRATE_PARAM_DISK_PORT"
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.
"Sys::Virt::Domain::MIGRATE_PARAM_MIGRATE_DISKS"
The list of disks to migrate when doing block storage migration. In contrast to other parameters whose values are plain strings, the parameter value should be an array reference, whose elements are in turn strings representing the disk target names.
"Sys::Virt::Domain::MIGRATE_PARAM_COMPRESSION"
The type of compression method use use, either "xbzrle" or "mt".
"Sys::Virt::Domain::MIGRATE_PARAM_COMPRESSION_MT_THREADS"
The number of compression threads to use
"Sys::Virt::Domain::MIGRATE_PARAM_COMPRESSION_MT_DTHREADS"
The number of decompression threads
"Sys::Virt::Domain::MIGRATE_PARAM_COMPRESSION_MT_LEVEL"
The compression level from 0 (no compression) to 9 (maximum compression)
"Sys::Virt::Domain::MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE"
The size of the cache for xbzrle compression
"Sys::Virt::Domain::MIGRATE_PARAM_PERSIST_XML"
The alternative persistent XML config to copy
"Sys::Virt::Domain::MIGRATE_PARAM_AUTO_CONVERGE_INITIAL"
The initial percentage to throttle guest vCPUs
"Sys::Virt::Domain::MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT"
The additional percentage step size to throttle guest vCPUs if progress is not made
"Sys::Virt::Domain::MIGRATE_PARAM_PARALLEL_CONNECTIONS"
The number of connections used during parallel migration.
"Sys::Virt::Domain::MIGRATE_PARAM_TLS_DESTINATION"
Override the destination host name used for TLS verification. 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 cetificate's hostname is known, this parameter can be used to pass this expected hostname when starting the migration.
"Sys::Virt::Domain::MIGRATE_PARAM_DISKS_URI"
The URI to use for initializing the domain migration for storage. 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 storage data.
$ddom = $dom->migrate(destcon, flags=0, dname=undef, uri=undef, bandwidth=0)
Migrate a domain to an alternative host. Use of positional parameters with "migrate" is deprecated in favour of passing a hash reference as described above.
$ddom = $dom->migrate2(destcon, dxml, flags, dname, uri, bandwidth)
Migrate a domain to an alternative host. This method is deprecated in favour of passing a hash ref to "migrate".
$ddom = $dom->migrate_to_uri(desturi, \%params, flags=0)
Migrate a domain to an alternative host. The "desturi" parameter should be a valid libvirt connection URI for the remote target host. The "flags" parameter takes one or more of the "Sys::Virt::Domain::MIGRATE_XXX" constants described later in this document. The %params parameter is a hash reference used to set various parameters for the migration operation, with the same keys described for the "migrate" API.
$dom->migrate_to_uri(desturi, flags, dname, bandwidth)
Migrate a domain to an alternative host. Use of positional parameters with "migrate_to_uri" is deprecated in favour of passing a hash reference as described above.
$dom->migrate_to_uri2(dconnuri, miguri, dxml, flags, dname, bandwidth)
Migrate a domain to an alternative host. This method is deprecated in favour of passing a hash ref to "migrate_to_uri".
$dom->migrate_set_max_downtime($downtime, $flags=0)
Set the maximum allowed downtime during migration of the guest. A longer downtime makes it more likely that migration will complete, at the cost of longer time blackout for the guest OS at the switch over point. The "downtime" parameter is measured in milliseconds. The $flags parameter is currently unused and defaults to zero.
$downtime = $dom->migrate_get_max_downtime($flags=0) Get the current value of the maximum downtime allowed during a migration of a guest. The returned <downtime> value is measured in milliseconds. The $flags parameter is currently unused and defaults to zero.
$dom->migrate_set_max_speed($bandwidth, $flags=0)
Set the maximum allowed bandwidth during migration of the guest. The "bandwidth" parameter is measured in MB/second. The $flags parameter takes zero or more of the constants:
$Sys::Virt::Domain::MIGRATE_MAX_SPEED_POSTCOPY
Set the post-copy speed instead of the pre-copy speed.
$bandwidth = $dom->migrate_get_max_speed($flags=0)
Get the maximum allowed bandwidth during migration fo the guest. The returned <bandwidth> value is measured in MB/second. The $flags parameter is accepts the same constants as "migrate_set_max_speed".
$dom->migrate_set_compression_cache($cacheSize, $flags=0)
Set the maximum allowed compression cache size during migration of the guest. The "cacheSize" parameter is measured in bytes. The $flags parameter is currently unused and defaults to zero.
$cacheSize = $dom->migrate_get_compression_cache($flags=0)
Get the maximum allowed compression cache size during migration of the guest. The returned <bandwidth> value is measured in bytes. The $flags parameter is currently unused and defaults to zero.
$dom->migrate_start_post_copy($flags=0)
Switch the domain from pre-copy to post-copy mode. This requires that the original migrate command had the "Sys::Virt::Domain::MIGRATE_POST_COPY" flag specified.
$dom->inject_nmi($flags)
Trigger an NMI in the guest virtual machine. The $flags parameter is currently unused and defaults to 0.
$dom->open_console($st, $devname, $flags)
Open the text console for a serial, parallel or paravirt console device identified by $devname, connecting it to the stream $st. If $devname is undefined, the default console will be opened. $st must be a "Sys::Virt::Stream" object used for bi-directional communication with the console. $flags is currently unused, defaulting to 0.
$dom->open_channel($st, $devname, $flags)
Open the text console for a data channel device identified by $devname, connecting it to the stream $st. $st must be a "Sys::Virt::Stream" object used for bi-directional communication with the channel. $flags is currently unused, defaulting to 0.
$dom->open_graphics($idx, $fd, $flags)
Open the graphics console for a guest, identified by $idx, counting from 0. The $fd should be a file descriptor for an anoymous socket pair. The $flags argument should be one of the constants listed at the end of this document, and defaults to 0.
$fd = $dom->open_graphics_fd($idx, $flags)
Open the graphics console for a guest, identified by $idx, counting from 0. The $flags argument should be one of the constants listed at the end of this document, and defaults to 0. The return value will be a file descriptor connected to the console which must be closed when no longer needed. This method is preferred over "open_graphics" since it will work correctly under sVirt mandatory access control policies.
Capture a screenshot of the virtual machine's monitor. The $screen parameter controls which monitor is captured when using a multi-head or multi-card configuration. $st must be a "Sys::Virt::Stream" object from which the data can be read. $flags is currently unused and defaults to 0. The mimetype of the screenshot is returned
@vcpuinfo = $dom->get_vcpu_info($flags=0)
Obtain information about the state of all virtual CPUs in a running guest domain. The returned list will have one element for each vCPU, where each elements contains a hash reference. The keys in the hash are, "number" the vCPU number, "cpu" the physical CPU on which the vCPU is currently scheduled, "cpuTime" the cumulative execution time of the vCPU, "state" the running state and "affinity" giving the allowed shedular placement. The value for "affinity" is a string representing a bitmask against physical CPUs, 8 cpus per character. To extract the bits use the "unpack" function with the "b*" template. NB The "state", "cpuTime", "cpu" values are only available if using $flags value of 0, and the domain is currently running; otherwise they will all be set to zero.
$dom->pin_vcpu($vcpu, $mask)
Pin the virtual CPU given by index $vcpu to physical CPUs given by $mask. The $mask is a string representing a bitmask against physical CPUs, 8 cpus per character.
$mask = $dom->get_emulator_pin_info()
Obtain information about the CPU affinity of the emulator process. The returned $mask is a bitstring against physical CPUs, 8 cpus per character. To extract the bits use the "unpack" function with the "b*" template.
$dom->pin_emulator($newmask, $flags=0)
Pin the emulator threads to the physical CPUs identified by the affinity in $newmask. The $newmask is a bitstring against the physical CPUa, 8 cpus per character. To create a suitable bitstring, use the "vec" function with a value of 1 for the "BITS" parameter.
@iothreadinfo = $dom->get_iothread_info($flags=0)
Obtain information about the state of all IOThreads in a running guest domain. The returned list will have one element for each IOThread, where each elements contains a hash reference. The keys in the hash are, "number" the IOThread number and "affinity" giving the allowed schedular placement. The value for "affinity" is a string representing a bitmask against physical CPUs, 8 cpus per character. To extract the bits use the "unpack" function with the "b*" template.
$dom->pin_iothread($iothread, $mask)
Pin the IOThread given by index $iothread to physical CPUs given by $mask. The $mask is a string representing a bitmask against physical CPUs, 8 cpus per character.
$dom->add_iothread($iothread, $flags=0)
Add a new IOThread by the $iothread value to the guest domain. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
$dom->del_iothread($iothread, $flags=0)
Delete an existing IOThread by the $iothread value from the guest domain. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
$dom->set_iothread($iothread, $params, $flags=0)
Set parameters for the IOThread by the $iothread value on the guest domain. The $params parameter is a hash reference whose keys are the "IOTHREAD STATS" constants documented later. The $flags parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted.
Requests the guests host physical CPU usage statistics, starting from host CPU <$startCpu> counting up to $numCpus. If $startCpu is -1 and $numCpus is 1, then the utilization across all CPUs is returned. Returns an array of hash references, each element containing stats for one CPU.
Returns a hash reference summarising the execution state of the background job. The elements of the hash are as follows:
The type of job, one of the JOB TYPE constants listed later in this document.
The elapsed time in milliseconds
The expected remaining time in milliseconds. Only set if the "type" is JOB_UNBOUNDED.
The total amount of data expected to be processed by the job, in bytes.
The current amount of data processed by the job, in bytes.
The expected amount of data remaining to be processed by the job, in bytes.
The total amount of mem expected to be processed by the job, in bytes.
The current amount of mem processed by the job, in bytes.
The expected amount of mem remaining to be processed by the job, in bytes.
The total amount of file expected to be processed by the job, in bytes.
The current amount of file processed by the job, in bytes.
The expected amount of file remaining to be processed by the job, in bytes.
Returns an array summarising the execution state of the background job. The $type value is one of the JOB TYPE constants listed later in this document. The $stats value is a hash reference, whose elements are one of the following constants.
The type of job, one of the JOB TYPE constants listed later in this document.

The $flags parameter defaults to zero and can take one of the following constants.

Return the stats of the most recently completed job.
Don't clear the completed stats after reading them.
The elapsed time in milliseconds
Time in milliseconds since the beginning of the migration job NOT including the time required to transfer control flow from the source host to the destination host.
The expected remaining time in milliseconds. Only set if the "type" is JOB_UNBOUNDED.
The total amount of data expected to be processed by the job, in bytes.
The current amount of data processed by the job, in bytes.
The expected amount of data remaining to be processed by the job, in bytes.
The total amount of mem expected to be processed by the job, in bytes.
The current amount of mem processed by the job, in bytes.
The expected amount of mem remaining to be processed by the job, in bytes.
The number of pages filled with a constant byte which have been transferred
The number of pages transferred without any compression
The number of bytes transferred without any compression
The bytes per second transferred
The number of memory pages dirtied per second
The memory page size in bytes
The total number of iterations over guest memory
The number of page requests received from the destination host during post-copy migration.
The total amount of file expected to be processed by the job, in bytes.
The current amount of file processed by the job, in bytes.
The expected amount of file remaining to be processed by the job, in bytes.
The bytes per second transferred
The percentage by which vCPUs are currently throttled
The size of the compression cache in bytes
The number of compressed bytes transferred
The number of compressed pages transferred
The number of changing pages not in compression cache
The number of changing pages in the compression cache but sent uncompressed since the compressed page was larger than the non-compressed page.
The number of milliseconds of downtime expected during migration switchover.
Real measured downtime (ms) NOT including the time required to transfer control flow from the source host to the destination host.
The number of milliseconds of time doing setup of the job
The type of operation associated with the job
Whether the job was successfully completed.
Possible total temporary disk space for the job in bytes
Current total temporary disk space for the job in bytes
The error message from a failed job

The values for the Sys::Virt::Domain::JOB_OPERATION field are

No known job type
The guest is starting
The guest is saving to disk
The guest is restoring from disk
The guest is migrating in from another host
The guest is migrating out to another host
The guest is saving a snapshot
The guest is reverting to a snapshot
The guest is saving a crash dump
The guest is performing a block backup
$dom->abort_job()
Aborts the currently executing job
Returns a hash reference summarising the execution state of the block job. The $path parameter should be the fully qualified path of the block device being changed. Valid $flags include:
Treat bandwidth value as bytes instead of MiB.
$dom->set_block_job_speed($path, $bandwidth, $flags=0)
Change the maximum I/O bandwidth used by the block job that is currently executing for $path. The $bandwidth argument is specified in MB/s. The $flags parameter can take the bitwise union of the values:
The $bandwidth parameter value is measured in bytes/s instead of MB/s.
$dom->abort_block_job($path, $flags=0)
Abort the current job that is executing for the block device associated with $path
$dom->block_pull($path, $bandwidth, $flags=0)
Merge the backing files associated with $path into the top level file. The $bandwidth parameter specifies the maximum I/O rate to allow in MB/s. The $flags parameter can take the bitwise union of the values:
The $bandwidth parameter value is measured in bytes/s instead of MB/s.
$dom->block_rebase($path, $base, $bandwidth, $flags=0)
Switch the backing path associated with $path to instead use $base. The $bandwidth parameter specifies the maximum I/O rate to allow in MB/s. The $flags parameter can take the bitwise union of the values:
The $bandwidth parameter value is measured in bytes/s instead of MB/s.
$dom->block_copy($path, $destxml, $params, $flags=0)
Copy contents of a disk image <$path> into the target volume described by $destxml which follows the schema of the <disk> element in the domain XML. The $params parameter is a hash of optional parameters to control the process
The maximum bandwidth in bytes per second.
The granularity in bytes of the copy process
The maximum amount of data in flight in bytes.
$dom->block_commit($path, $base, $top, $bandwidth, $flags=0)
Commit changes there were made to the temporary top level file $top. Takes all the differences between $top and $base and merge them into $base. The $bandwidth parameter specifies the maximum I/O rate to allow in MB/s. The $flags parameter can take the bitwise union of the values:
The $bandwidth parameter value is measured in bytes instead of MB/s.
$count = $dom->num_of_snapshots()
Return the number of saved snapshots of the domain
@names = $dom->list_snapshot_names()
List the names of all saved snapshots. The names can be used with the "lookup_snapshot_by_name"
@snapshots = $dom->list_snapshots()
Return a list of all snapshots currently known to the domain. The elements in the returned list are instances of the Sys::Virt::DomainSnapshot class. This method requires O(n) RPC calls, so the "list_all_snapshots" method is recommended as a more efficient alternative.
Return a list of all domain snapshots associated with this domain. The elements in the returned list are instances of the Sys::Virt::DomainSnapshot class. The $flags parameter can be used to filter the list of return domain snapshots.
Return the domain snapshot with a name of $name. The returned object is an instance of the Sys::Virt::DomainSnapshot class.
$dom->has_current_snapshot()
Returns a true value if the domain has a currently active snapshot
$snapshot = $dom->current_snapshot()
Returns the currently active snapshot for the domain.
$snapshot = $dom->create_snapshot($xml[, $flags])
Create a new snapshot from the $xml. The $flags parameter accepts the SNAPSHOT CREATION constants listed in "Sys::Virt::DomainSnapshots".
Return a list of all domain checkpoints associated with this domain. The elements in the returned list are instances of the Sys::Virt::DomainCheckpoint class. The $flags parameter can be used to filter the list of return domain checkpoints.
Return the domain checkpoint with a name of $name. The returned object is an instance of the Sys::Virt::DomainCheckpoint class.
$checkpoint = $dom->create_checkpoint($xml[, $flags])
Create a new checkpoint from the $xml. The $flags parameter accepts the CHECKPOINT CREATION constants listed in "Sys::Virt::DomainCheckpoints".
$dom->backup_begin($backupxml, $checkpointxml=undef, $flags=0);
Start a point-in-time backup job for the specified disks of a running domain. The $backupxml parameter describes the backup operation, including which disks to use. The optional $checkpointxml parameter can be used to create a checkpoint covering to the same point in time as the backup. The optional $flags parameter can be one of the following constants:
Assume that the output/temporary files for the backup have been precreated by the caller with the correct size and format.
$xml = $dom->backup_get_xml_description($flags=0);
Get the XML description of the currently executing backup job. If there is no backup job then an error is raised.
$dom->fs_trim($mountPoint, $minimum, $flags=0);
Issue an FS_TRIM command to the device at $mountPoint to remove chunks of unused space that are at least $minimum bytes in length. $flags is currently unused and defaults to zero.
$dom->fs_freeze(\@mountPoints, $flags=0);
Freeze all the filesystems associated with the @mountPoints array reference. If <@mountPoints> is an empty list, then all filesystems will be frozen. $flags is currently unused and defaults to zero.
$dom->fs_thaw(\@mountPoints, $flags=0);
Thaw all the filesystems associated with the @mountPoints array reference. If <@mountPoints> is an empty list, then all filesystems will be thawed. $flags is currently unused and defaults to zero.
@fslist = $dom->get_fs_info($flags=0);
Obtain a list of all guest filesystems. The returned list will contain one element for each filesystem, whose value will be a hash reference with the following keys
The name of the guest device that is mounted
The filesystem type (eg 'ext4', 'fat', 'ntfs', etc)
The location in the filesystem tree of the mount
An array reference containing list of device aliases associated with the guest device. The device aliases correspond to disk target names in the guest XML configuration
@nics = $dom->get_interface_addresses($src, $flags=0);
Obtain a list of all guest network interfaces. The $src parameter is one of the constants
Extract the DHCP server lease information
Query the guest OS via an agent
Extract from the local ARP tables

The returned list will contain one element for each interface. The values in the list will be a hash reference with the following keys

The name of the guest interface that is mounted
The hardware address, aka MAC, if available.
An array reference containing list of IP addresses associated with the guest NIC. Each element in the array is a further hash containing
The IP address string
The IP address network prefix
The IP address type (IPv4 vs IPv6)
$dom->send_process_signal($pid, $signum, $flags=0);
Send the process $pid the signal $signum. The $signum value must be one of the constants listed later, not a POSIX or Linux signal value. $flags is currently unused and defaults to zero.
$dom->set_block_threshold($dev, $threshold, $flags=0);
Set the threshold level for delivering the EVENT_ID_BLOCK_THRESHOLD if the device or backing chain element described by $dev is written beyond the set $threshold level. The threshold level is unset once the event fires. The event might not be delivered at all if libvirtd was not running at the moment when the threshold was reached.
$dom->set_lifecycle_action($type, $action, $flags=0)
Changes the actions of lifecycle events for domain represented as <on_$type>$action</on_$type> in the domain XML.
$info = $dom->get_launch_security_info($flags=0)
Get information about the domain launch security policy. $flags is currently unused and defaults to zero. The returned hash may contain the following keys
$info = $dom->get_guest_info($types, $flags=0)
Get information about the domain guest configuration. The $types parameter determines what pieces of information are returned and should be the bitwise or of the following constants:
Active user information
Misc operating system information
The guest timezone
The guest hostname
Filesystem mount information
Block device information

$flags is currently unused and defaults to zero.

$dom->set_agent_response_timeout($timeout, $flags=0)
Set the amount of time to wait for the agent to respond to a command. $timeout is a positive integer representing the number of seconds to wait, or one of the constants:
Wait forever with no timeout
Don't want at all, return immediately
Use the hypervisor driver's default timeout

The $flags parameter is currently unused and defaults to zero.

Retrieve the list of authorized SSH keys for the user account $user. The $flags parameter is currently unused and defaults to zero.
$dom->authorized_ssh_keys_set($user, \@keys, $flags=0)
Update the list of authorized SSH keys for the user account $user. The @keys parameter should be an array reference containing the new keys, if any. The default behaviour is to set the authorized SSH keys to the exact set specified in @keys. This can be modified via the $flags parameter which takes the following constants
Append @keys to the current set of keys, rather than replacing the existing keys.
Remove @keys from the current set of keys, rather than replacing the existing keys. It is not an error if the keys do not exist.
Retrieve a list of messages associated with the domain. The optional $flags parameter can accept zero or more of
Warnings about use of deprecated features
Warnings about actions that have tainting the domain
$dom->start_dirty_rate_calc($dom, $secs, $flags=0)
Request calculation of the domain's memory dirty rate over the next $secs seconds. $flags is currently unused and defaults to zero.

A number of the APIs take a "flags" parameter. In most cases passing a value of zero will be satisfactory. Some APIs, however, accept named constants to alter their behaviour. This section documents the current known constants.

DOMAIN STATE

The domain state constants are useful in interpreting the "state" key in the hash returned by the "get_info" method.

The domain is active, but is not running / blocked (eg idle)
The domain is active and running
The domain is active, but execution is blocked
The domain is active, but execution has been paused
The domain is active, but in the shutdown phase
The domain is inactive, and shut down.
The domain is inactive, and crashed.
The domain is active, but in power management suspend state

CONTROL INFO

The following constants can be used to determine what the guest domain control channel status is

The control channel has a fatal error
The control channel is ready for jobs
The control channel is busy
The control channel is busy with a job

If the status is "Sys::Virt::Domain::CONTROL_ERROR", then one of the following constants describes the reason

There is no reason for the error available
The reason for the error is unknown
There was an internal error in libvirt
There was an error speaking to the monitor

DOMAIN CREATION

The following constants can be used to control the behaviour of domain creation

Keep the guest vCPUs paused after starting the guest
Automatically destroy the guest when the connection is closed (or fails)
Do not use OS I/O cache if starting a domain with a saved state image
Boot the guest, even if there was a saved snapshot
Validate the XML document against the XML schema

DOMAIN DEFINE

The following constants can be used to control the behaviour of domain define operations

Validate the XML document against the XML schema

KEYCODE SETS

The following constants define the set of supported keycode sets

The Linux event subsystem keycodes
The original XT keycodes
The AT Set1 keycodes (aka XT)
The AT Set2 keycodes (aka AT)
The AT Set3 keycodes (aka PS2)
The OS-X keycodes
The XT keycodes from the Linux Keyboard driver
The USB HID keycode set
The Windows keycode set
The XT keycode set, with the extended scancodes using the high bit of the first byte, instead of the low bit of the second byte.
A deprecated alias for "Sys::Virt::Domain::KEYCODE_SET_QNUM"

MEMORY PEEK

The following constants can be used with the "memory_peek" method's flags parameter

Indicates that the offset is using virtual memory addressing.
Indicates that the offset is using physical memory addressing.

VCPU STATE

The following constants are useful when interpreting the virtual CPU run state

The virtual CPU is not online
The virtual CPU is executing code
The virtual CPU is waiting to be scheduled

VCPU HOST PLACEMENT STATE

The following constants are useful when interpreting the virtual CPU host placement

The virtual CPU is not online
The virtual CPU placement is not available from this hypervisor

OPEN GRAPHICS CONSTANTS

The following constants are used when opening a connection to the guest graphics server

Skip authentication of the client

OPEN CONSOLE CONSTANTS

The following constants are used when opening a connection to the guest console

Force opening of the console, disconnecting any other open session
Check if the console driver supports safe operations

OPEN CHANNEL CONSTANTS

The following constants are used when opening a connection to the guest channel

Force opening of the channel, disconnecting any other open session

XML DUMP OPTIONS

The following constants are used to control the information included in the XML configuration dump

Report the persistent inactive configuration for the guest, even if it is currently running.
Include security sensitive information in the XML dump, such as passwords.
Update the CPU model definition to match the current executing state.
Update the XML to allow migration to older versions of libvirt

DEVICE HOTPLUG OPTIONS

The following constants are used to control device hotplug operations

Modify the domain in its current state
Modify only the live state of the domain
Modify only the persistent config of the domain
Force the device to be modified

MEMORY OPTIONS

The following constants are used to control memory change operations

Modify the current state
Modify only the live state of the domain
Modify only the persistent config of the domain
Modify the maximum memory value

CONFIG OPTIONS

The following constants are used to control what configuration a domain update changes

Modify the current state
Modify only the live state of the domain
Modify only the persistent config of the domain

MIGRATE OPTIONS

The following constants are used to control how migration is performed

Migrate the guest without interrupting its execution on the source host.
Manage the migration process over a direct peer-2-peer connection between the source and destination host libvirtd daemons.
Tunnel the migration data over the libvirt daemon connection, rather than the native hypervisor data transport. Requires PEER2PEER flag to be set.
Make the domain persistent on the destination host, defining its configuration file upon completion of migration.
Remove the domain's persistent configuration after migration completes successfully.
Do not re-start execution of the guest CPUs on the destination host after migration completes.
Copy the complete contents of the disk images during migration
Copy the incrementally changed contents of the disk images during migration
Do not allow changes to the virtual domain configuration while migration is taking place. This option is automatically implied if doing a peer-2-peer migration.
Migrate even if the compatibility check indicates the migration will be unsafe to the guest.
Migrate the guest config if the guest is not currently running
Enable compression of the migration data stream
Abort if an I/O error occurrs on the disk
Force convergance of the migration operation by throttling guest runtime
Pin memory for RDMA transfer
Enable support for post-copy migration
Setting this flag will cause the migration to attempt to use the TLS environment configured by the hypervisor in order to perform the migration. If incorrectly configured on either source or destination, the migration will fail.
Send memory pages to the destination host through several network connections. See "Sys::Virt::Domain::MIGRATE_PARAM_PARALLEL_*" parameters for configuring the parallel migration.

UNDEFINE CONSTANTS

The following constants can be used when undefining virtual domain configurations

Also remove any managed save image when undefining the virtual domain
Also remove any snapshot metadata when undefining the virtual domain.
Also remove any NVRAM state file when undefining the virtual domain.
keep NVRAM state file when undefining the virtual domain.
Also remove any checkpoint metadata when undefining the virtual domain.

JOB TYPES

The following constants describe the different background job types.

No job is active
A job with a finite completion time is active
A job with an unbounded completion time is active
The job has finished, but isn't cleaned up
The job has hit an error, but isn't cleaned up
The job was aborted at user request, but isn't cleaned up

MEMORY PARAMETERS

The following constants are useful when getting/setting memory parameters for guests

The maximum memory the guest can use.
The memory upper limit enforced during memory contention.
The minimum memory guaranteed to be reserved for the guest.
The maximum swap the guest can use.
The value of an unlimited memory parameter

BLKIO PARAMETERS

The following parameters control I/O tuning for the domain as a whole

The I/O weight parameter
The per-device I/O weight parameter
The per-device I/O bytes read per second
The per-device I/O operations read per second
The per-device I/O bytes write per second
The per-device I/O operations write per second

BLKIO TUNING PARAMETERS

The following parameters control I/O tuning for an individual guest disk.

The total bytes processed per second.
The bytes read per second.
The bytes written per second.
The total I/O operations processed per second.
The I/O operations read per second.
The I/O operations written per second.
The maximum total bytes processed per second.
The maximum bytes read per second.
The maximum bytes written per second.
The maximum total I/O operations processed per second.
The maximum I/O operations read per second.
The maximum I/O operations written per second.
The maximum I/O operations per second
A string representing a group name to allow sharing of I/O throttling quota between multiple drives
The duration in seconds allowed for maximum total bytes processed per second.
The duration in seconds allowed for maximum bytes read per second.
The duration in seconds allowed for maximum bytes written per second.
The duration in seconds allowed for maximum total I/O operations processed per second.
The duration in seconds allowed for maximum I/O operations read per second.
The duration in seconds allowed for maximum I/O operations written per second.

SCHEDULER CONSTANTS

The VM cap tunable
The CPU shares tunable
The VM limit tunable
The VM reservation tunable
The VM shares tunable
The VCPU period tunable
The VCPU quota tunable
The VM global period tunable
The VM global quota tunable
The VM weight tunable

NUMA PARAMETERS

The following constants are useful when getting/setting the guest NUMA memory policy

The NUMA policy mode
The NUMA nodeset mask

The following constants are useful when interpreting the "Sys::Virt::Domain::NUMA_MODE" parameter value

Allocation is mandatory from the mask nodes
Allocation is preferred from the masked nodes
Allocation is interleaved across all masked nodes
Allocation is determined by the host using the masked nodes.

INTERFACE PARAMETERS

The following constants are useful when getting/setting the per network interface tunable parameters

The average inbound bandwidth
The peak inbound bandwidth
The burstable inbound bandwidth
The minimum inbound bandwidth
The average outbound bandwidth
The peak outbound bandwidth
The burstable outbound bandwidth

PERF EVENTS

The following constants defined performance events which can be monitored for a guest

The CMT event counter which can be used to measure the usage of cache (bytes) by applications running on the platform. It corresponds to the "perf.cmt" field in the *Stats APIs.
The MBML event counter which can be used to monitor the amount of data (bytes/s) sent through the memory controller on the socket. It corresponds to the "perf.mbml" field in the *Stats APIs.
The MBMT event counter which can be used to monitor total system bandwidth (bytes/s) from one level of cache to another. It corresponds to the "perf.mbmt" field in the *Stats APIs.
The cache_misses perf event counter which can be used to measure the count of cache misses by applications running on the platform. It corresponds to the "perf.cache_misses" field in the *Stats APIs.
The cache_references perf event counter which can be used to measure the count of cache hits by applications running on the platform. It corresponds to the "perf.cache_references" field in the *Stats APIs.
The cpu_cycles perf event counter which can be used to measure how many cpu cycles one instruction needs. It corresponds to the "perf.cpu_cycles" field in the *Stats APIs.
The instructions perf event counter which can be used to measure the count of instructions by applications running on the platform. It corresponds to the "perf.instructions" field in the *Stats APIs.
The branch_instructions perf event counter which can be used to measure the count of instructions by applications running on the platform. It corresponds to the "perf.branch_instructions" field in the *Stats APIs.
The branch_misses perf event which can be used to measure the count of branch misses by applications running on the platform. It corresponds to the "perf.branch_misses" field in the *Stats APIs.

IOTHREAD STATS

The following constants defined IOThread statistics which can be monitored for a guest

The maximum polling time that can be used by polling algorithm in ns. The polling time starts at 0 (zero) and is the time spent by the guest to process IOThread data before returning the CPU to the host. The polling time will be dynamically modified over time based on the poll_grow and poll_shrink parameters provided.
This provides a value for the dynamic polling adjustment algorithm to use to grow its polling interval up to the poll_max_ns value.
This provides a value for the dynamic polling adjustment algorithm to use to shrink its polling interval when the polling interval exceeds the poll_max_ns value.

VCPU FLAGS

The following constants are useful when getting/setting the VCPU count for a guest

Flag to request the live value
Flag to request the persistent config value
Flag to request the current config value
Flag to request adjustment of the maximum vCPU value
Flag to request the guest VCPU mask
Flag to make vcpus added hot(un)pluggable

STATE CHANGE EVENTS

The following constants allow domain state change events to be interpreted. The events contain both a state change, and a reason.

Indicates that a persistent configuration has been defined for the domain.
The defined configuration is newly added
The defined configuration is an update to an existing configuration
The defined configuration is a rename of an existing configuration
The defined configuration was restored from a snapshot
The domain has resumed execution
The domain resumed because migration has completed. This is emitted on the destination host.
The domain resumed because the admin unpaused it.
The domain resumed because it was restored from a snapshot
The domain resumed but post-copy is running in background
The domain has started running
The domain was booted from shutoff state
The domain started due to an incoming migration
The domain was restored from saved state file
The domain was restored from a snapshot
The domain was woken up from suspend
The domain has stopped running
The domain stopped because guest operating system has crashed
The domain stopped because administrator issued a destroy command.
The domain stopped because of a fault in the host virtualization environment.
The domain stopped because it was migrated to another machine.
The domain was saved to a state file
The domain stopped due to graceful shutdown of the guest.
The domain was stopped due to a snapshot
The domain has shutdown but is not yet stopped
The domain finished shutting down
The domain shutdown due to host trigger
The domain shutdown due to guest trigger
The domain has stopped executing, but still exists
The domain has been suspended due to offline migration
The domain has been suspended due to administrator pause request.
The domain has been suspended due to a block device I/O error.
The domain has been suspended due to resume from snapshot
The domain has been suspended due to the watchdog triggering
The domain has been suspended due to restore from saved state
The domain has been suspended due to an API error
The domain has been suspended for post-copy migration
The domain has been suspended due post-copy migration failing
The persistent configuration has gone away
The domain configuration has gone away due to it being removed by administrator.
The undefined configuration is a rename of an existing configuration
The domain has stopped running
The domain has suspend to RAM.
The domain has suspend to Disk.
The domain has crashed
The domain has crashed due to a kernel panic
The domain has crashed and reloaded itself

EVENT ID CONSTANTS

Domain lifecycle events
Soft / warm reboot events
RTC clock adjustments
File IO errors, typically from disks
Watchdog device triggering
Graphics client connections.
File IO errors, typically from disks, with a root cause
Errors from the virtualization control channel
Completion status of asynchronous block jobs, identified by source file name.
Completion status of asynchronous block jobs, identified by target device name.
Changes in disk media
CDROM media tray state
Power management initiated suspend to RAM
Power management initiated suspend to Disk
Power management initiated wakeup
Balloon target changes
Asynchronous guest device addition
Asynchronous guest device removal
Changes of any domain tuning parameters. The callback will be provided with a hash listing all changed parameters. The later DOMAIN TUNABLE constants can be useful when accessing the hash keys
Domain guest agent lifecycle events. The "state" parameter to the callback will match one of the constants

The second parameter, "reason", matches one of the following constants

Domain migration progress iteration. The "iteration" parameter to the callback will specify the number of iterations migration has made over guest RAM.
Domain background job completion notification. The callback provides a hash containing the job stats. The keyus in the hash are the same as those used with the "Sys::Virt::Domain::get_job_stats()" method.
Guest device removal has failed.
The domain metadata has changed
The event occurs when the hypervisor detects that the given storage element was written beyond the point specified by threshold. The event is useful for thin-provisioned storage.
The event occurs when the hypervisor detects hardware memory corruption.
The event occurs when the guest accepts a request to change the memory device size.

IO ERROR EVENT CONSTANTS

These constants describe what action was taken due to the IO error.

No action was taken, the error was ignored & reported as success to guest
The guest is paused since the error occurred
The error has been reported to the guest OS

WATCHDOG EVENT CONSTANTS

These constants describe what action was taken due to the watchdog firing

No action was taken, the watchdog was ignored
The guest is paused since the watchdog fired
The guest is powered off after the watchdog fired
The guest is reset after the watchdog fired
The guest attempted to gracefully shutdown after the watchdog fired
No action was taken, the watchdog was logged
An NMI was injected into the guest after the watchdog fired

GRAPHICS EVENT PHASE CONSTANTS

These constants describe the phase of the graphics connection

The initial client connection
The client has been authenticated & the connection is running
The client has disconnected

GRAPHICS EVENT ADDRESS CONSTANTS

These constants describe the format of the address

An IPv4 address
An IPv6 address
An UNIX socket path address

DISK CHANGE EVENT CONSTANTS

These constants describe the reason for a disk change event

The disk media was cleared, as its source was missing when attempting to start the guest
The disk device was dropped, as its source was missing when attempting to start the guest

TRAY CHANGE CONSTANTS

These constants describe the reason for a tray change event

The tray was closed
The tray was opened

DOMAIN BLOCK JOB TYPE CONSTANTS

The following constants identify the different types of domain block jobs

An unknown block job type
The block pull job type
The block copy job type
The block commit job type
The block active commit job type
The block backup job type

DOMAIN BLOCK JOB COMPLETION CONSTANTS

The following constants can be used to determine the completion status of a block job

A successfully completed block job
An unsuccessful block job
A block job canceled byy the user
A block job is running

DOMAIN BLOCK REBASE CONSTANTS

The following constants are useful when rebasing block devices

Limit copy to top of source backing chain
Reuse existing external file for copy
Make destination file raw
Start a copy job
Treat destination as a block device instead of file
Keep backing chain referenced using relative names

DOMAIN BLOCK COPY CONSTANTS

The following constants are useful when copying block devices

Limit copy to top of source backing chain
Reuse existing external file for copy
Don't force usage of recoverable job for the copy operation

DOMAIN BLOCK JOB ABORT CONSTANTS

The following constants are useful when aborting job copy jobs

Request only, do not wait for completion
Pivot to mirror when ending a copy job

DOMAIN BLOCK COMMIT JOB CONSTANTS

The following constants are useful with block commit job types

Delete any files that are invalid after commit
NULL base means next backing file, not whole chain
Allow two phase commit when top is active layer
Keep backing chain referenced using relative names

DOMAIN SAVE / RESTORE CONSTANTS

The following constants can be used when saving or restoring virtual machines

Do not use OS I/O cache when saving state.
Mark the saved state as paused to prevent the guest CPUs starting upon restore.
Mark the saved state as running to allow the guest CPUs to start upon restore.

DOMAIN CORE DUMP CONSTANTS

The following constants can be used when triggering domain core dumps

Do not pause execution while dumping the guest
Crash the guest after completing the core dump
Do not use OS I/O cache when writing core dump
Reset the virtual machine after finishing the dump
Only include guest RAM in the dump, not the device state

DESTROY CONSTANTS

The following constants are useful when terminating guests using the "destroy" API.

Destroy the guest using the default approach
Destroy the guest in a graceful manner

SHUTDOWN CONSTANTS

The following constants are useful when requesting that a guest terminate using the "shutdown" API

Shutdown using the hypervisor's default mechanism
Shutdown by issuing a command to a guest agent
Shutdown by injecting an ACPI power button press
Shutdown by talking to initctl (containers only)
Shutdown by sending SIGTERM to the init process
Shutdown by issuing a paravirt power control command

REBOOT CONSTANTS

The following constants are useful when requesting that a guest terminate using the "reboot" API

Reboot using the hypervisor's default mechanism
Reboot by issuing a command to a guest agent
Reboot by injecting an ACPI power button press
Reboot by talking to initctl (containers only)
Reboot by sending SIGHUP to the init process
Reboot by issuing a paravirt power control command

METADATA CONSTANTS

The following constants are useful when reading/writing metadata about a guest

The short human friendly title of the guest
The long free text description of the guest
The structured metadata elements for the guest

DISK ERROR CONSTANTS

The following constants are useful when interpreting disk error codes

No error
The host storage has run out of free space
An unspecified error has occurred.

MEMORY STATISTIC CONSTANTS

Swap in
Swap out
Minor faults
Major faults
Resident memory
Unused memory
Available memory
Actual balloon limit
Amount of usable memory
Time of last stats refresh from guest
Disk cache size
The amount of successful huge page allocations
The amount of failed huge page allocations

DOMAIN LIST CONSTANTS

The following constants can be used when listing domains

Only list domains that are currently active (running, or paused)
Only list domains that are set to automatically start on boot
Only list domains that have a stored snapshot
Only list domains that are currently inactive (shutoff, saved)
Only list domains that have current managed save state
Only list domains that are not set to automatically start on boto
Only list domains that do not have any managed save state
Only list domains that do not have a stored snapshot
Only list domains that are not running, paused or shutoff
Only list domains that are paused
Only list domains which have a persistent config
Only list domains that are currently running
Only list domains that are currently shutoff
Only list domains that do not have a persistent config
Only list domains that have a stored checkpoint
Only list domains that do not have a stored checkpoint

SEND KEY CONSTANTS

The following constants are to be used with the "send_key" API

The maximum number of keys that can be sent in a single call to "send_key"

BLOCK STATS CONSTANTS

The following constants provide the names of well known block stats fields

The number of I/O errors
The number of flush requests
The time spent processing flush requests
The amount of data read
The number of read requests
The time spent processing read requests
The amount of data written
The number of write requests
The time spent processing write requests

CPU STATS CONSTANTS

The following constants provide the names of well known cpu stats fields

The total CPU time, including both hypervisor and vCPU time.
THe total time in kernel
The total time in userspace
The total vCPU time.

CPU STATS CONSTANTS

The following constants provide the names of well known schedular parameters

The duration of the time period for scheduling the emulator
The quota for the emulator in one schedular time period
The duration of the time period for scheduling the iothread
The quota for the iothread in one schedular time period

DOMAIN STATS FLAG CONSTANTS

The following constants are used as flags when requesting bulk domain stats from "Sys::Virt::get_all_domain_stats".

Include stats for active domains
Include stats for inactive domains
Include stats for other domains
Include stats for paused domains
Include stats for persistent domains
Include stats for running domains
Include stats for shutoff domains
Include stats for transient domains
Require that all requested stats fields are returned
Get stats for image backing files too
Skip stats if they can't be acquired without waiting

DOMAIN STATS FIELD CONSTANTS

The following constants are used to control which fields are returned for stats queries.

Balloon statistics
Block device info
CPU usage info
Network interface info
General lifecycle state
Virtual CPU info
Performance event counter values
IOThread performance statistics values
Memory bandwidth statistics values
Memory dirty rate statistics

PROCESS SIGNALS

The following constants provide the names of signals which can be sent to guest processes. They mostly correspond to POSIX signal names.

SIGNOP
SIGHUP
SIGINT
SIGQUIT
SIGILL
SIGTRAP
SIGABRT
SIGBUS
SIGFPE
SIGKILL
SIGUSR1
SIGSEGV
SIGUSR2
SIGPIPE
SIGALRM
SIGTERM
SIGSTKFLT
SIGCHLD
SIGCONT
SIGSTOP
SIGTSTP
SIGTTIN
SIGTTOU
SIGURG
SIGXCPU
SIGXFSZ
SIGVTALRM
SIGPROF
SIGWINCH
SIGPOLL
SIGPWR
SIGSYS
SIGRT0
SIGRT1
SIGRT2
SIGRT3
SIGRT4
SIGRT5
SIGRT6
SIGRT7
SIGRT8
SIGRT9
SIGRT10
SIGRT11
SIGRT12
SIGRT13
SIGRT14
SIGRT15
SIGRT16
SIGRT17
SIGRT18
SIGRT19
SIGRT20
SIGRT21
SIGRT22
SIGRT23
SIGRT24
SIGRT25
SIGRT26
SIGRT27
SIGRT28
SIGRT29
SIGRT30
SIGRT31
SIGRT32

DOMAIN TUNABLE CONSTANTS

The following constants are useful when accessing domain tuning parameters in APIs and events

Proportional CPU weight
Emulator thread CPU pinning mask
Emulator thread CPU period
Emulator thread CPU quota
Iothread thread CPU period
Iothread thread CPU quota
VCPU thread pinning mask
VCPU thread period
VCPU thread quota
VM global period
VM global quota
The name of guest disks
Read throughput in bytes per sec
Read throughput in I/O operations per sec
Total throughput in bytes per sec
Total throughput in I/O operations per sec
Write throughput in bytes per sec
Write throughput in I/O operations per sec
Maximum read throughput in bytes per sec
Maximum read throughput in I/O operations per sec
Maximum total throughput in bytes per sec
Maximum total throughput in I/O operations per sec
Maximum write throughput in bytes per sec
Maximum write throughput in I/O operations per sec
The maximum I/O operations per second
The duration in seconds allowed for maximum total bytes processed per second.
The duration in seconds allowed for maximum bytes read per second.
The duration in seconds allowed for maximum bytes written per second.
The duration in seconds allowed for maximum total I/O operations processed per second.
The duration in seconds allowed for maximum I/O operations read per second.
The duration in seconds allowed for maximum I/O operations written per second.
The name of the blkdev group
The I/O threads pinning

DOMAIN LIFECYCLE CONSTANTS

The following constants are useful when setting action for lifecycle events.

The poweroff lifecycle event type
The reboot lifecycle event type
The crash lifecycle event type

DOMAIN LIFECYCLE ACTION CONSTANTS

The destroy lifecycle action
The restart lifecycle action
The restart-rename lifecycle action
The preserve lifecycle action
The coredump-destroy lifecycle action
The coredump-restart lifecycle action

MEMORY FAILURE ACTION CONSTANTS

The failure could be ignored
An MCE was injected to the guest
The failure is non-recoverable and the hypervisor was not able to handle it
The failure is non-recoverable and the guest was not able to handle it.

MEMORY FAILURE RECIPIENT CONSTANTS

The memory failure was in hypervisor address space
The memory failure was in guest address space

MEMORY FAILURE FLAG CONSTANTS

Whether the flag is action-required or action-optional
The failure occurred while the previous fault was being handled.

MEMORY DIRTY RATE STATUS CONSTANTS

The dirty rate is not being measured currently.
The dity rate is in the process of being measured
The dirty rate has been measured

Daniel P. Berrange <berrange@redhat.com>

Copyright (C) 2006 Red Hat Copyright (C) 2006-2007 Daniel P. Berrange

This program is free software; you can redistribute it and/or modify it under the terms of either the GNU General Public License as published by the Free Software Foundation (either version 2 of the License, or at your option any later version), or, the Artistic License, as specified in the Perl README file.

Sys::Virt, Sys::Virt::Error, "http://libvirt.org"

2021-12-21 perl v5.34.0