add_domain


Description:

[ Version ( since = "1.7.4" ) ]
public int32 add_domain (string dom, AddDomain? optargs) throws Error

add the disk(s) from a named libvirt domain

This function adds the disk(s) attached to the named libvirt domain dom. It works by connecting to libvirt, requesting the domain and domain XML from libvirt, parsing it for disks, and calling guestfs_session_add_drive_opts on each one.

The number of disks added is returned. This operation is atomic: if an error is returned, then no disks are added.

This function does some minimal checks to make sure the libvirt domain is not running (unless readonly is true). In a future version we will try to acquire the libvirt lock on each disk.

Disks must be accessible locally. This often means that adding disks from a remote libvirt connection (see <ulink url='http://libvirt.org/remote.html'> http://libvirt.org/remote.html </ulink>) will fail unless those disks are accessible via the same device path locally too.

The optional libvirturi parameter sets the libvirt URI (see <ulink url='http://libvirt.org/uri.html'> http://libvirt.org/uri.html </ulink>). If this is not set then we connect to the default libvirt URI (or one set through an environment variable, see the libvirt documentation for full details).

The optional live flag controls whether this call will try to connect to a running virtual machine guestfsd process if it sees a suitable &lt;channel&gt; element in the libvirt XML definition. The default (if the flag is omitted) is never to try. See "ATTACHING TO RUNNING DAEMONS" in guestfs(3) for more information.

If the allowuuid flag is true (default is false) then a UUID *may* be passed instead of the domain name. The dom string is treated as a UUID first and looked up, and if that lookup fails then we treat dom as a name as usual.

The optional readonlydisk parameter controls what we do for disks which are marked &lt;readonly/&gt; in the libvirt XML. Possible values are:

readonlydisk = "error" If readonly is false:

The whole call is aborted with an error if any disk with the &lt;readonly/&gt; flag is found.

If readonly is true:

Disks with the &lt;readonly/&gt; flag are added read-only.

readonlydisk = "read" If readonly is false:

Disks with the &lt;readonly/&gt; flag are added read-only. Other disks are added read/write.

If readonly is true:

Disks with the &lt;readonly/&gt; flag are added read-only.

readonlydisk = "write" (default) If readonly is false:

Disks with the &lt;readonly/&gt; flag are added read/write.

If readonly is true:

Disks with the &lt;readonly/&gt; flag are added read-only.

readonlydisk = "ignore" If readonly is true or false:

Disks with the &lt;readonly/&gt; flag are skipped.

The other optional parameters are passed directly through to guestfs_session_add_drive_opts.

Parameters:

this

A GuestfsSession object

optargs

a GuestfsAddDomain containing optional arguments

Returns:

the returned value, or -1 on error




2022 vala-language.org