---
name: "ocf_heartbeat_VirtualDomain"
section: "7"
platform: "linux"
package: "resource-agents"
version: "1:4.16.0-3+deb13u2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ocf_heartbeat_VirtualDomain"
---

# ocf\_heartbeat\_VirtualDomain(7)

Manages virtual domains through the libvirt virtualization framework

## NAME

ocf\_heartbeat\_VirtualDomain - Manages virtual domains through the libvirt virtualization framework

## SYNOPSIS

**VirtualDomain** \[start \| stop \| status \| monitor \| migrate\_to \| migrate\_from \| meta-data \| validate-all\]

## DESCRIPTION

Resource agent for a virtual domain (a.k.a. domU, virtual machine, virtual environment etc., depending on context) managed by libvirtd.

This resource agent may be configured for *native migration* if available in the cluster manager. For Pacemaker, the *allow-migrate="true"* meta attribute enables native migration.

## SUPPORTED PARAMETERS

**config**

Absolute path to the libvirt configuration file, for this virtual domain.

(unique, required, string, no default)

**hypervisor**

Hypervisor URI to connect to. See the libvirt documentation for details on supported URI formats. The default is system dependent. Determine the system's default uri by running 'virsh --quiet uri'.

(optional, string, no default)

**force\_stop**

Always forcefully shut down ("destroy") the domain on stop. The default behavior is to resort to a forceful shutdown only after a graceful shutdown attempt has failed. You should only set this to true if your virtual domain (or your virtualization backend) does not support graceful shutdown.

(optional, boolean, default 0)

**migration\_transport**

Transport used to connect to the remote hypervisor while migrating. Please refer to the libvirt documentation for details on transports available. If this parameter is omitted, the resource will use libvirt's default transport to connect to the remote hypervisor.

(optional, string, no default)

**migration\_user**

The username will be used in the remote libvirt remoteuri/migrateuri. No user will be given (which means root) in the username if omitted

If remoteuri is set, migration\_user will be ignored.

(optional, string, no default)

**migration\_downtime**

Define max downtime during live migration in milliseconds

(optional, integer, default 0)

**migration\_speed**

Define live migration speed per resource in MiB/s

(optional, integer, default 0)

**migration\_network\_suffix**

Use a dedicated migration network. The migration URI is composed by adding this parameters value to the end of the node name. If the node name happens to be an FQDN (as opposed to an unqualified host name), insert the suffix immediately prior to the first period (.) in the FQDN. At the moment Qemu/KVM and Xen migration via a dedicated network is supported.

Note: Be sure this composed host name is locally resolvable and the associated IP is reachable through the favored network. This suffix will be added to the remoteuri and migrateuri parameters.

See also the migrate\_options parameter below.

(optional, string, no default)

**migrateuri**

You can also specify here if the calculated migrate URI is unsuitable for your environment.

If migrateuri is set then migration\_network\_suffix, migrateport and

\--migrateuri in migrate\_options are effectively ignored. Use "%n" as the placeholder for the target node name.

Please refer to the libvirt documentation for details on guest migration.

(optional, string, no default)

**migrate\_options**

Extra virsh options for the guest live migration. You can also specify here --migrateuri if the calculated migrate URI is unsuitable for your environment. If --migrateuri is set then migration\_network\_suffix and migrateport are effectively ignored. Use "%n" as the placeholder for the target node name.

Please refer to the libvirt documentation for details on guest migration.

(optional, string, no default)

**monitor\_scripts**

To additionally monitor services within the virtual domain, add this parameter with a list of scripts to monitor.

Note: when monitor scripts are used, the start and migrate\_from operations will complete only when all monitor scripts have completed successfully. Be sure to set the timeout of these operations to accommodate this delay.

(optional, string, no default)

**autoset\_utilization\_cpu**

If set true, the agent will detect the number of domainU's vCPUs from virsh, and put it into the CPU utilization of the resource when the monitor is executed.

(optional, boolean, default true)

**autoset\_utilization\_host\_memory**

If set true, the agent will detect the number of \*Max memory\* from virsh, and put it into the host\_memory utilization of the resource when the monitor is executed.

(optional, boolean, default true)

**autoset\_utilization\_hv\_memory**

If set true, the agent will detect the number of \*Max memory\* from virsh, and put it into the hv\_memory utilization of the resource when the monitor is executed.

(optional, boolean, default true)

**unset\_utilization\_cpu**

If set true then the agent will remove the cpu utilization resource when the monitor is executed.

(optional, boolean, default false)

**unset\_utilization\_host\_memory**

If set true then the agent will remove the host\_memory utilization resource when the monitor is executed.

(optional, boolean, default false)

**unset\_utilization\_hv\_memory**

If set true then the agent will remove the hv\_memory utilization resource when the monitor is executed.

(optional, boolean, default false)

**migrateport**

This port will be used in the qemu migrateuri. If unset, the port will be a random highport.

(optional, integer, no default)

**remoteuri**

Use this URI as virsh connection URI to commuicate with a remote hypervisor.

If remoteuri is set then migration\_user and migration\_network\_suffix are effectively ignored. Use "%n" as the placeholder for the target node name.

Please refer to the libvirt documentation for details on guest migration.

(optional, string, no default)

**save\_config\_on\_stop**

Changes to a running VM's config are normally lost on stop. This parameter instructs the RA to save the configuration back to the xml file provided in the "config" parameter.

(optional, boolean, no default)

**sync\_config\_on\_stop**

Setting this automatically enables save\_config\_on\_stop. When enabled this parameter instructs the RA to call csync2 -x to synchronize the file to all nodes. csync2 must be properly set up for this to work.

(optional, boolean, no default)

**snapshot**

Path to the snapshot directory where the virtual machine image will be stored. When this parameter is set, the virtual machine's RAM state will be saved to a file in the snapshot directory when stopped. If on start a state file is present for the domain, the domain will be restored to the same state it was in right before it stopped last. This option is incompatible with the 'force\_stop' option.

(optional, string, no default)

**backingfile**

When the VM is used in Copy-On-Write mode, this is the backing file to use (with its full path). The VMs image will be created based on this backing file. This backing file will never be changed during the life of the VM.

(optional, string, no default)

**stateless**

If set to true and backingfile is defined, the start of the VM will systematically create a new qcow2 based on the backing file, therefore the VM will always be stateless. If set to false, the start of the VM will use the COW (\<vmname\>.qcow2) file if it exists, otherwise the first start will create a new qcow2 based on the backing file given as backingfile.

(optional, boolean, default false)

**copyindirs**

List of directories for the virt-copy-in before booting the VM. Used only in stateless mode.

(optional, string, no default)

**shutdown\_mode**

virsh shutdown method to use. Please verify that it is supported by your virsh toolsed with 'virsh help shutdown' When this parameter is set --mode shutdown\_mode is passed as an additional argument to the 'virsh shutdown' command. One can use this option in case default acpi method does not work. Verify that this mode is supported by your VM. By default --mode is not passed.

(optional, string, no default)

**start\_resources**

Start the virtual storage pools and networks used by the virtual machine before starting it or before live migrating it.

(optional, boolean, default false)

## SUPPORTED ACTIONS

This resource agent supports the following actions (operations):

**start**

Starts the resource. Suggested minimum timeout: 90s.

**stop**

Stops the resource. Suggested minimum timeout: 90s.

**status**

Performs a status check. Suggested minimum timeout: 30s. Suggested interval: 10s.

**monitor**

Performs a detailed status check. Suggested minimum timeout: 30s. Suggested interval: 10s.

**migrate\_from**

Executes steps necessary for migrating the resource *away from* the node. Suggested minimum timeout: 60s.

**migrate\_to**

Executes steps necessary for migrating the resource *to* the node. Suggested minimum timeout: 120s.

**meta-data**

Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5s.

**validate-all**

Performs a validation of the resource configuration. Suggested minimum timeout: 5s.

## EXAMPLE CRM SHELL

The following is an example configuration for a VirtualDomain resource using the [**crm**(8)](/crm/8.md) shell:

```
primitive p_VirtualDomain ocf:heartbeat:VirtualDomain \
  params \
    config=string \
  meta allow-migrate="true" \
  op monitor depth="0" timeout="30s" interval="10s"
```

## EXAMPLE PCS

The following is an example configuration for a VirtualDomain resource using [**pcs**(8)](/pcs/8.md)

```
pcs resource create p_VirtualDomain ocf:heartbeat:VirtualDomain \
  config=string \
  op monitor OCF_CHECK_LEVEL="0" timeout="30s" interval="10s"
```

## SEE ALSO

**http://clusterlabs.org/**

## AUTHOR

**ClusterLabs contributors (see the resource agent source for information about individual authors)**
