OpenBSD manual page server

Manual Page Search Parameters

VMCTL(8) System Manager's Manual VMCTL(8)

vmctlcontrol the virtual machine daemon

vmctl [-v] command [arg ...]

The vmctl utility is used to control the virtual machine monitor (VMM) subsystem. A VMM manages virtual machines (VMs) on a host. The VMM subsystem is responsible for creating, destroying, and executing VMs.

The -v option enables verbose mode. Within the commands, the size argument can be specified with a human-readable scale, using the format described in scan_scaled(3). The id argument can be either a numeric, non-zero identifier or alternatively the name of a virtual machine.

The name argument can only consist of alphanumeric characters, as well as '.', '-', and '_', and must start with a letter.

The disk argument is used by commands that take a path to a disk image file. It may be prefixed with a format prefix (raw:disk or qcow2:disk) in order to specify the disk image format. If left unspecified, the format defaults to ‘raw’ if it cannot be derived automatically.

The commands are as follows:

Using cu(1) connect to the console of the VM with the specified id.
[-b base | -i disk] [-s size] disk
Create a VM disk image file with the specified disk path.
For ‘qcow2’, a base image may be specified. The base image is not modified and the derived image contains only the changes written by the VM.
Copy and convert the input disk to the newly created disk. This option conflicts with -b base.
Specify the size of the new disk image, rounded to megabytes. If the -b option is specified, the size must match the size of the base image. For the -i option, the size cannot be smaller than the input disk size. The size can be omitted with the -b and -i options and will be obtained from the base or input image respectively.
Load additional configuration from the specified file.
Disable or enable verbose debug logging.
Pause a VM with the specified id.
Receive a VM from standard input and start it with the specified name.
Remove all stopped VMs and reload the configuration from the default configuration file. VMs that are currently running will not have their configuration reloaded. To reload configurations for currently running VMs, stop those VMs before issuing the reload command.
[all | switches | vms]
Reset the running state, reset switches, or reset and terminate all vms.
Send a VM with the specified id to standard output and terminate it. The VM is paused during send processing. Data sent to standard output contains the VM parameters and its memory, not the disk image.

In order to move a VM from one host to another, disk files must be synced between the send and the receive processes and must be located under the same path.

[-r] [id]
An alias for the status command.
[-cL] [-B device] [-b path] [-d disk] [-i count] [-m size] [-n switch] [-r path] [-t nameidname
Start a new VM name with the specified parameters. An existing VM may be started by referencing its id.
Force system to boot from the specified device for this boot. device can be set to:

Boot the CD-ROM image.
Boot from disk.
Perform a PXE boot using the first network interface.

Currently net is only supported when booting a kernel using the -b flag while disk and cdrom only work with VMs booted using BIOS.

Boot the VM with the specified OpenBSD kernel or custom BIOS image. If not specified, the default is to boot using the BIOS image in /etc/firmware/vmm-bios. If the VM is an existing VM, use the provided image for only the next boot.
Automatically connect to the VM console.
Use a disk image at the specified disk path (may be specified multiple times to add multiple disk images).
Number of network interfaces to add to the VM.
Add a local network interface. vmd(8) will auto-generate an IPv4 subnet for the interface, configure a gateway address on the VM host side, and run a simple DHCP/BOOTP server for the VM. See LOCAL INTERFACES below for more information on how addresses are calculated and assigned when using the -L option.
Memory size of the VM, rounded to megabytes. The default is 512M. The maximum amount of memory assignable to a VM is governed by the datasize parameter for the vmd user in /etc/login.conf.
Add a network interface that is attached to the specified virtual switch. See the SWITCH CONFIGURATION section in vm.conf(5) for more information.
ISO image file for virtual CD-ROM. This image file will be available in the selected VM as a SCSI CD-ROM device attached to a virtio SCSI adapter (e.g. vioscsi(4)).
Use an existing VM with the specified name as a template to create a new VM instance. The instance will inherit settings from the parent VM, except for exclusive options such as disk, interface lladdr, and interface names.
[-r] [id]
List VMs running on the host, optionally listing just the selected VM id. If the -r flag is present, the output will only contain running VMs.
[-fw] [-a | id]
Stop (terminate) a VM defined by the specified VM id or all running VMs (-a). By default, a graceful shutdown will be attempted if the VM supports the vmmci(4) device.

The following options can be specified when stopping a VM:

Forcefully stop the VM without attempting a graceful shutdown.
Wait until the VM has been terminated.
Unpause (resume from a paused state) a VM with the specified id.
Wait until the specified VM has stopped.

If the -i, -L, or -n options are specified during VM startup, a corresponding number of host-side tap(4) interfaces will be allocated and mapped to the vio(4) interfaces inside the guest VM. This tap/vio interface mapping allows guest network traffic to be manipulated by the host. Any valid host-side interface configuration may be performed on these tap interfaces, such as bridging (via veb(4)), or using pf(4) nat-to rules to create private or host-side NATed networks, as desired. For each tap(4) network interface on the host, vmd(8) will set the interface's description to allow easy identification of the corresponding VM by ID, interface number, and name:

# ifconfig tap0
	lladdr fe:e1:ba:d8:50:d1
	description: vm1-if0-myvm
	index 15 priority 0 llprio 3
	groups: tap
	status: active

Local interfaces can be used to easily configure VM networking without needing to manually assign network addresses. A local interface is added to a VM using the -L option to the 'vmctl start' command and results in the addition of a vio(4) interface inside the VM and a corresponding tap(4) interface on the host. When using local interfaces, vmd(8) will provide DHCP services to the guest VM and offer addresses selected from the IPv4 range. From within the range, vmd(8) allocates a pair of addresses for the guest-side vio(4) and host-side tap(4) interfaces as follows:

For the first local interface:

For the second and subsequent local interface(s):

Multiple -L options can be provided to the 'vmctl start' command, if more than one interface is desired. Local interfaces are assigned to the VM before any other interfaces specified with the -i option (thus, local interfaces, if requested, are numbered starting at vio0 inside the guest VM).

If NAT is desired, the net.inet.ip.forwarding sysctl(8) must also be set to 1.

When using local interfaces, the DHCP configuration offered to the guest VM specifies the address of the corresponding host tap(4) interface as both the default route and the (sole) nameserver. Guest VM traffic can optionally be NATed through the host with an entry in the host machine's /etc/pf.conf similar to the following:

pass out on egress from to any nat-to (egress)

If desired, DNS queries originating from guest VMs can be redirected to a different DNS server with an entry in the host machine's /etc/pf.conf similar to the following:

pass in proto { udp tcp } from to any port domain \
      rdr-to $dns_server port domain

Default configuration file.
UNIX-domain socket used for communication with vmd(8).

The vmctl utility exits 0 on success, and >0 if an error occurs. vmctl may fail due to one of the following reasons:

Create a 4.5 Gigabyte disk image, disk.img:

$ vmctl create -s 4.5G disk.img

Convert a disk image from the ‘raw’ format to ‘qcow2’:

$ vmctl create -i disk.img disk.qcow2

Create a new VM with 1GB memory, one network interface, one disk image ('disk.img') and boot from kernel '/bsd':

# vmctl start -m 1G -i 1 -b /bsd -d disk.img "myvm"

Start a new VM instance with the name 'myvm' from a pre-configured VM 'openbsd.4G':

# vmctl start -t "openbsd.4G" -d mydisk.img "myvm"

Terminate VM number 1:

# vmctl stop 1

pf(4), tap(4), veb(4), vio(4), vmm(4), vm.conf(5), rc.conf(8), sysctl(8), vmd(8)

The vmctl command first appeared in OpenBSD 5.9.

Mike Larkin <> and Reyk Floeter <>.

May 4, 2024 OpenBSD-current