Product SiteDocumentation Site

Chapter 4. Guest Domains

4.1. Domain overview
4.2. Listing domains
4.3. Lifecycle control
4.3.1. Provisioning
4.3.2. Save / restore
4.3.3. Migration
4.3.4. Autostart
4.4. Monitoring performance
4.4.1. Domain performance
4.4.2. vCPU performance
4.4.3. I/O statistics
4.5. Domain configuration
4.5.1. Boot modes
4.5.2. Memory / CPU resources
4.5.3. Lifecycle controls
4.5.4. Clock sync
4.5.5. Features
4.6. Device configuration
4.6.1. Emulator
4.6.2. Disks
4.6.3. Networking
4.6.4. Filesystems
4.6.5. Mice & tablets
4.6.6. USB device passthrough
4.6.7. PCI device passthrough
4.7. Live configuration change
4.7.1. Memory ballooning
4.7.2. CPU hotplug
4.7.3. Device hotplug / unplug
4.7.4. Device media change
4.8. Security model
4.9. Event notifications
4.10. Tuning
4.10.1. Scheduler parameters
4.10.2. NUMA placement

4.1. Domain overview

A guest domain can refer to either a running virtual machine or a configuration which can be used to launch a virtual machine. The connection object provides APIs to enumerate the guest domains, create new guest domains and manage existing domains. A guest domain is represented with the virDomainPtr object and has a number of unique identifiers:
Unique identifiers
  • ID: positive integer, unique amongst running guest domains on a single host. An inactive domain does not have an ID. If the host OS is a virtual domain, it is given a ID of zero by default. For example, with the Xen hypervisor, Dom0 indicates a guest domain. Other domain IDs will be allocated starting at 1, and incrementing each time a new domain starts. Typically domain IDs will not be re-used until the entire ID space wraps around. The domain ID space is at least 16 bits in size, but often extends to 32 bits.
  • name: short string, unique amongst all guest domains on a single host, both running and inactive. For maximum portability between hypervisors applications should only rely on being able to use the characters a-Z,0-9,-,_ in names. Many hypervisors will store inactive domain configurations as files on disk, based on the domain name.
  • UUID: 16 unsigned bytes, guaranteed to be unique amongst all guest domains on any host. RFC 4122 defines the format for UUIDs and provides a recommended algorithm for generating UUIDs with guaranteed uniqueness. If the host OS is itself a virtual domain, then by convention it will be given a UUID of all zeros. This is the case with the Xen hypervisor, where Dom0 is a guest domain itself.
A guest domain may be transient, or persistent. A transient guest domain can only be managed while it is running on the host and, when powered off, all trace of it will disappear. A persistent guest domain has its configuration maintained in a data store on the host by the hypervisor, in an implementation defined format. Thus when a persistent guest is powered off, it is still possible to manage its inactive config. A transient guest can be turned into a persistent guest on the fly by defining a configuration for it.
Once an application has a unique identifier for a domain, it will often want to obtain the corresponding virDomainPtr object. There are three, imaginatively named, methods to do lookup existing domains, virDomainLookupByID, virDomainLookupByName and virDomainLookupByUUID. Each of these takes a connection object as first parameter, and the domain identifier as the other. They will return NULL if no matching domain exists. The connection's error object can be queried to find specific details of the error if required.
        int domainID = 6;
        virDomainPtr dom;

        dom = virDomainLookupByID(conn, domainID);
Example 4.1. Fetching a domain object from an ID

        int domainName = "someguest";
        virDomainPtr dom;

        dom = virDomainLookupByName(conn, domainName);
Example 4.2. Fetching a domain object from an name

        char *domainUUID = "00311636-7767-71d2-e94a-26e7b8bad250";
        virDomainPtr dom;

        dom = virDomainLookupByUUIDString(conn, domainUUID);
Example 4.3. Fetching a domain object from an UUID

For convenience of this document, the UUID example used the printable format of UUID. There is an equivalent method which accepts the raw bytes unsigned char[]