vm-control

A utility to manage Virtual Machines (VMs).

The vm-control utility creates and manages VMs by communicating with a Hypervisor. It is typically run on a desktop, bastion or build machine.

Usage

vm-control supports several sub-commands. There are many command-line flags which provide parameters for these sub-commands. The most commonly used parameters are -fleetManagerHostname or -hypervisorHostname which specify either the Fleet Manager or a specific Hypervisor to communicate with. The basic usage pattern is:

vm-control [flags...] command [args...]

Built-in help is available with the command:

vm-control -h

Some of the sub-commands available are:

Security

The Hypervisor restricts RPC access using TLS client authentication. vm-control will load certificate and key files from the ~/.ssl directory. vm-control will present these certificates to the Hypervisor. If one of the certificates is signed by a certificate authority that the Hypervisor trusts, the Hypervisor will grant access. Most operations only require a certificate that proves identity. The Keymaster is a good choice for issuing these certificates.

Importing virsh (libvirt) VMs

A libvirt VM may be imported into the Hypervisor. Once the VM is committed it is removed from the libvirt database and is fully "owned" by the Hypervisor. Importing a VM requires root access on the Hypervisor (the vm-control tool will use the sudo command if needed).

There are a few simple steps that should be followed to import a VM. In the example below, the MAC address of the VM to be imported is 52:54:de:ad:be:ef and the hostname (DNS entry) is jump.prod.company.com. The IP address of the VM may also be used. In either case, the hostname or IP address provided must match the libvirt domain name. If the VM has multiple network interfaces, the MAC and IP address/FQDN for each interface must be provided in pairs.

Exporting VMs to virsh (libvirt)

A local VM on the Hypervisor may be exported to a libvirt VM. Once the libvirt VM is committed the original VM is removed from the database and is fully "owned" by libvirt. Exporting a VM requires root access on the Hypervisor (the vm-control tool will use the sudo command if needed).

There are a few simple steps that should be followed to export a VM. In the example below, the hostname (DNS entry) of the VM to be exported is jump.prod.company.com. The IP address of the VM may also be used. In either case, the hostname or IP address provided will become the new libvirt domain name.

VM Placement Command

An optional local command to be used when making VM placement decisions (when creating, copying, migrating or restoring VMs) may be specified using the -placementCommand option when -placement=command. The placement command may read from the standard input a JSON payload describing the Hypervisors available (based on other location and tag matching options) and the VmInfo describing the VM that will be placed. The name of the selected Hypervisor must be written to the standard output.

The schema of the data presented to the standard input is:

struct {
    Hypervisors []fm_proto.Hypervisor `json:",omitempty"`
    VmInfo      hyper_proto.VmInfo
}

See fm_proto and hyper_proto for sub-schema definitions.