VMCTL(8) | System Manager's Manual | VMCTL(8) |
vmctl
—
vmctl |
[-v ] command
[arg ...] |
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 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:
console
idcreate
disk [-b
base | -i
disk] [-s
size]-b
base-i
disk-b
base.-s
size-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 ommitted with the
-b
and -i
options and
will be obtained from the base or input image respectively.load
filenamelog
brief
|
verbose
pause
idreceive
namereload
reset
[all
| switches
|
vms
]switches
, or reset
and terminate all vms
.send
idIn 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.
show
[id]status
command.start
name [-cL
]
[-B
device]
[-b
path]
[-d
disk]
[-i
count]
[-m
size]
[-n
switch]
[-r
path]
[-t
name]-B
deviceCurrently net is only supported when
booting a kernel using the -b
flag while
disk and cdrom only work
with BIOS images.
-b
path-c
-d
disk-i
count-L
-L
option.-m
size-n
switch-r
path-t
nameNote that the VM name supplied to the 'start' command can only consist of alphanumeric characters, including '.', '-', and '_'. The name cannot start with '.', '-' or '_'.
status
[id]stop
[id | -a
]
[-fw
]-a
).
By default, a graceful shutdown will be attempted if the VM supports the
vmmci(4) device. Once stopped, if the VM
was not defined in a configuration file, then it is removed.
The following options can be specified when stopping a VM:
unpause
idwait
idIf the -i
option is 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
bridge(4)), or using
pf(4) nat-to rules to create private or
host-side NATed networks, as desired.
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).
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 $ext_if from 100.64.0.0/10 to any nat-to $ext_if
If NAT is desired, the net.inet.ip.forwarding sysctl(8) must also be set to 1.
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 100.64.0.0/10 to any port domain \ rdr-to $dns_server port domain
vmctl
utility exits 0 on success,
and >0 if an error occurs. vmctl
may fail
due to one of the following reasons:
$ vmctl create disk.img -s 4.5G
Convert a disk image from the ‘raw’ format to ‘qcow2’:
$ vmctl create disk.qcow2 -i disk.img
Create a new VM with 1GB memory, one network interface, one disk image ('disk.img') and boot from kernel '/bsd':
# vmctl start "myvm" -m 1G -i 1 -b /bsd -d disk.img
Start a new VM instance with the name 'myvm' from a pre-configured VM 'openbsd.4G':
# vmctl start "myvm" -t "openbsd.4G" -d mydisk.img
vmd(8) will create a new tap(4) network interface on the host side and set the description to indicate the VM by ID, interface number, and name:
# ifconfig tap0 tap0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 lladdr fe:e1:ba:d8:50:d1 description: vm1-if0-myvm index 15 priority 0 llprio 3 groups: tap status: active
Terminate VM number 1:
# vmctl stop 1
vmctl
command first appeared in
OpenBSD 5.9.
December 18, 2018 | OpenBSD-current |