.\" $OpenBSD: vm.conf.5,v 1.11 2016/10/20 19:44:09 jmc Exp $ .\" .\" Copyright (c) 2015 Mike Larkin .\" Copyright (c) 2015 Reyk Floeter .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate: October 20 2016 $ .Dt VM.CONF 5 .Os .Sh NAME .Nm vm.conf .Nd virtual machine configuration .Sh DESCRIPTION .Nm is the configuration file to configure the virtual machine monitor (VMM) subsystem. A VMM manages virtual machines (VMs) on a .Ar host . The VMM subsystem is responsible for creating, destroying, and executing VMs. .Sh SECTIONS .Nm is divided into three main sections: .Bl -tag -width xxxx .It Sy Macros User-defined variables may be defined and used later, simplifying the configuration file. .It Sy VM Configuration Configuration for each individual virtual machine. .It Sy Switch Configuration Configuration for virtual switches. .El .Pp Within the sections, the .Ar bytes argument can be specified with a human-readable scale, using the format described in .Xr scan_scaled 3 . .Pp The current line can be extended over multiple lines using a backslash .Pq Sq \e . Comments can be put anywhere in the file using a hash mark .Pq Sq # , and extend to the end of the current line. Care should be taken when commenting out multi-line text: the comment is effective until the end of the entire block. .Pp Argument names not beginning with a letter, digit, underscore, or slash must be quoted. .Pp Additional configuration files can be included with the .Ic include keyword, for example: .Bd -literal -offset indent include "/etc/vm1.example.com.conf" .Ed .Sh MACROS Macros can be defined that will later be expanded in context. Macro names must start with a letter, digit, or underscore, and may contain any of those characters. Macro names may not be reserved words (for example, .Ic vm , .Ic memory , or .Ic disk ) . Macros are not expanded inside quotes. .Pp For example: .Bd -literal -offset indent ramdisk="/bsd.rd" vm "vm1.example.com" { memory 512M kernel $ramdisk } .Ed .Sh VM CONFIGURATION Each .Ic vm section starts with a declaration of the virtual machine .Ar name : .Bl -tag -width Ds .It Ic vm Ar name Brq ... This name can be any string, and is typically a hostname. .El .Pp Followed by a block of parameters that is enclosed in curly brackets: .Bl -tag -width Ds .It Cm enable Automatically start the VM. This is the default if neither .Cm enable nor .Cm disable is specified. .It Cm disable Do not start this VM. .It Cm disk Ar path Disk image file (may be specified multiple times to add multiple disk images). .It Cm kernel Ar path Kernel to load when booting the VM. .It Cm memory Ar bytes Memory size of the VM, in bytes, rounded to megabytes. .It Cm interface Oo name Oc Op Brq ... Network interface to add to the VM. The optional .Ar name can be either .Sq tap to select the next available .Xr tap 4 interface on the VM host side (the default) or .Ar tapN to select a specific one. Valid options are: .Bl -tag -width Ds .It Cm group Ar group-name Assign the interface to a specific interface .Dq group . For example, this can be used to write .Xr pf.conf 5 rules for several VM interfaces in the same group. The .Ar group-name must not end with a digit. .It Cm lladdr Ar etheraddr Change the link layer address (MAC address) of the interface on the VM guest side. If not specified, a randomized address will be assigned by .Xr vmd 8 . .It Cm switch Ar name Set the virtual switch by .Ar name . See the .Sx SWITCH CONFIGURATION section about virtual switches. This option is ignored if a switch with a matching name cannot be found. .It Cm up Start the interface forwarding packets. This is the default. .It Cm down Stop the interface from forwarding packets. .El .It Cm interfaces Ar count Optional minimum number of network interfaces to add to the VM. If the .Ar count is greater than the number of .Ic interface statements, additional default interfaces will be added. .El .Sh SWITCH CONFIGURATION A virtual switch allows VMs to communicate with other network interfaces on the host system via either .Xr bridge 4 or .Xr switch 4 . The network interface for each virtual switch defined in .Nm is automatically created by .Xr vmd 8 , but it is also possible to pre-configure switch interfaces using .Xr hostname.if 5 or .Xr ifconfig 8 (see the .Sx BRIDGE and .Sx SWITCH sections in .Xr ifconfig 8 accordingly). When a VM is started, virtual network interfaces which are assigned to a virtual switch have their .Xr tap 4 interface automatically added into the corresponding .Xr bridge 4 or .Xr switch 4 interface underlying the virtual switch. .Pp Virtual switches can be configured at any point in the configuration file. Each .Ic switch section starts with a declaration of the virtual switch: .Bl -tag -width Ds .It Ic switch Ar name Brq ... This name can be any string, and is typically a network name. .El .Pp Followed by a block of parameters that is enclosed in curly brackets: .Bl -tag -width Ds .It Cm add Ar interface Add .Ar interface as a member of the switch. Any network interface can be added, typically as an uplink interface, but it can be a member of at most one switch. .It Cm enable Automatically configure the switch. This is the default if neither .Cm enable nor .Cm disable is specified. .It Cm disable Do not configure this switch. .It Cm group Ar group-name Assign each interface to a specific interface .Dq group . For example, this can be used to write .Xr pf.conf 5 rules for several VM interfaces in the same group. The .Ar group-name must not end with a digit. .It Cm interface Ar name Set the .Xr switch 4 or .Xr bridge 4 network interface of this switch. If not specified, .Ar bridge0 will be used where the interface unit will be incremented for each switch, e.g.\& .Ar bridge0 , bridge1 , ... If the type is changed to .Ar switch0 , it will be used for each following switch. .It Cm up Start the switch forwarding packets. This is the default. .It Cm down Stop the switch from forwarding packets. .El .Sh EXAMPLES Create a new VM with 512MB memory, 1 network interface connected to .Dq uplink , one disk image .Sq disk.img and boot from kernel .Sq /bsd : .Bd -literal -offset indent vm "vm2.example.com" { memory 512M disk "/var/vmm/vm2-disk.img" kernel "/bsd" interface { switch "uplink" } } .Ed .Pp Create the switch "uplink" with an additional physical network interface: .Bd -literal -offset indent switch "uplink" { add em0 } .Ed .Sh SEE ALSO .Xr vmm 4 , .Xr vmctl 8 , .Xr vmd 8 .Sh HISTORY The .Nm file format first appeared in .Ox 5.9 . .Sh AUTHORS .An -nosplit .An Mike Larkin Aq Mt mlarkin@openbsd.org and .An Reyk Floeter Aq Mt reyk@openbsd.org .