1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
.\" $OpenBSD: vm.conf.5,v 1.56 2021/03/01 14:27:44 kn Exp $
.\"
.\" Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
.\" Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
.\"
.\" 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: March 1 2021 $
.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.
.Pp
.Nm
is divided into the following main sections:
.Bl -tag -width xxxx
.It Sy Macros
User-defined variables may be defined and used later, simplifying the
configuration file.
.It Sy Global Configuration
Global settings for
.Xr vmd 8 .
.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
boot $ramdisk
}
.Ed
.Sh GLOBAL CONFIGURATION
The following setting can be configured globally:
.Bl -tag -width Ds
.It Ic local prefix Ar address Ns Li / Ns Ar prefix
Set the network prefix that is used to allocate subnets for
local interfaces, see
.Ic local interface
in the
.Sx VM CONFIGURATION
section below.
The default is
.Ar 100.64.0.0/10 .
.It Ic local inet6 Op Ic prefix Ar address Ns Li / Ns Ar prefix
Enable IPv6 on local interfaces and allocate routable subnets.
If the prefix is not specified,
a random prefix from the
.Dq unique local
network range
.Ar fd00::/8
will be generated on startup.
The specified prefix length must be /64 or smaller.
.It Cm socket owner Ar user : Ns Ar group
Set the control socket owner to the specified user and group.
Users with access to the control socket will be allowed to use
.Nm vmctl
for restricted access to
.Nm vmd .
If only
.Ar user
is given,
only the user is set.
If only
.Pf : Ar group
is given,
only the group is set.
The default is
.Ar root : Ns Ar wheel .
.It Ic staggered start parallel Ar parallelism Ic delay Ar seconds
Start all configured VMs in a staggered fashion with
.Ar parallelism
instances in parallel every
.Ar delay
seconds.
Defaults to
.Ar parallelism
equal to number of CPUs and a
.Ar delay
of 30 seconds.
.El
.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 ...
The
.Ar name
can only consist of alphanumeric characters, as well as '.', '-', and '_',
and must start with a letter.
Typically this is a hostname.
.El
.Pp
Followed by a block of parameters that is enclosed in curly brackets:
.Bl -tag -width Ds
.It Cm allow instance Brq ...
Set the permissions to create VM instances.
See
.Sx VM INSTANCES .
.It Cm boot Ar path
Kernel or BIOS image to load when booting the VM.
If not specified, the default is to boot using the BIOS image in
.Pa /etc/firmware/vmm-bios .
.It Cm boot device Ar device
Force VM to boot from
.Ar device .
Valid values are:
.Bl -tag -width "cdrom"
.It Ar cdrom
Boot the ISO image file specified using the
.Ic cdrom
parameter.
.It Ar disk
Boot from the disk image file specified using the
.Ic disk
parameter.
.It Ar net
Boot the kernel specified using the
.Ic boot
parameter as if the VM was network booted.
In addition, the DHCP lease will advertise
.Dq auto_install
in the bootfile option making it suitable for use with
.Xr autoinstall 8 .
Note, this is not to be confused with
.Xr pxeboot 8
but rather a simulated network boot.
.El
.Pp
Currently
.Ar disk
and
.Ar cdrom
only work with VMs booted using BIOS.
.It Cm cdrom Ar path
ISO image file.
.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 Op Cm format Ar fmt
Disk image file (may be specified multiple times to add multiple disk images).
The format may be specified as either
.Ar qcow2
or
.Ar raw .
If left unspecified, the format defaults to
.Pa raw
if it cannot be derived automatically.
.It Oo Cm local Oc 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.
.Pp
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 be longer than 15 characters or end with a digit,
as described in
.Xr ifconfig 8 .
.It Oo Cm locked Oc Cm lladdr Op 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 .
If the
.Cm locked
keyword is specified,
.Xr vmd 8
will drop packets from the VM with altered source addresses.
.It Cm rdomain Ar rdomainid
Attach the interface to the routing domain with the specified
.Ar rdomainid .
If attaching to a switch that also has an
.Ar rdomainid
set, the
.Ar rdomainid
configured for the interface takes precedence.
.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
.Pp
A
.Cm local
interface 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.
This option can be used for layer 3 mode without configuring a switch.
.Pp
If the global
.Cm local inet6
option is enabled, a routable IPv6 gateway address will be generated
on the host side.
Unlike the IPv4 option,
.Nm vmd
does not respond to DHCPv6 or router solicitation messages itself.
Use
.Xr rad 8
listening on the interface group, e.g.\&
.Ar interface tap
for auto-configuring the VMs accordingly.
.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.
.It Cm memory Ar bytes
Memory size of the VM, in bytes, rounded to megabytes.
The default is 512M.
.It Cm owner Ar user : Ns Ar group
Set the owner of the VM to the specified user and group.
The owner will be allowed to start or stop the VM, pause or unpause the VM,
and open the VM's console.
If only
.Ar user
is given,
only the user is set.
If only
.Pf : Ar group
is given,
only the group is set.
.El
.Sh VM INSTANCES
It is possible to use configured or running VMs as a template for
additional instances of the VM.
An instance is just like a normal
.Ic vm
and is configured with the following declaration of the virtual machine
.Ar name :
.Bl -tag -width Ds
.It Ic vm Ar parent Ic instance Ar name Brq ...
A virtual machine can be created as an instance of any other configured VM.
.El
.Pp
The new instance will inherit settings from the VM
.Ar parent ,
except for exclusive options such as
.Ic disk ,
.Ic interface lladdr ,
or
.Ic interface name .
The configuration options are identical to the
.Sx VM CONFIGURATION ,
but restricted to the allowed instance options.
.Pp
The allowed instance options are configured in the
.Ar parent
VM:
.Bl -tag -width Ds
.It Cm allow instance Brq ...
Allow users to use this VM as a template for VM instances.
By default, the root user can always create instances without
restrictions and users or non-root owners cannot create instances.
An instance will inherit the configuration from the VM and the user,
if permitted, will be allowed to configure individual VM options.
.El
.Pp
Valid options are:
.Bl -tag -width Ds
.It Cm boot
Allow user to configure the kernel or BIOS image.
The user needs read access to the image.
.It Cm cdrom
Allow user to configure the ISO file.
The user needs read access to the file.
.It Cm disk
Allow user to configure the disk images.
The user needs read and write access to image and instances are not
allowed to reuse disks from the parent VM.
.It Cm instance
Allow user to create additional instances from the instances.
.It Cm interface
Allow user to change network interface settings.
.It Cm memory
Allow user to configure the memory size.
.It Cm owner Ar user Ns Op : Ns Ar group
Allow the specified user or group to create the instances.
The owner will be allowed to create VM instances, start or stop the
instances, pause or unpause the instances, and open the instances'
consoles.
.It Cm owner Pf : Ar group
Set the owner to the specified group.
.El
.Sh SWITCH CONFIGURATION
A virtual switch allows VMs to communicate with other network interfaces on the
host system via either
.Xr bridge 4 ,
.Xr switch 4
or
.Xr veb 4 .
The network interface for each virtual switch defined in
.Nm
is pre-configured using
.Xr hostname.if 5
or
.Xr ifconfig 8
(see the BRIDGE and 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 enable
Automatically configure the switch.
This is the default if neither
.Cm enable
nor
.Cm disable
is specified.
.It Cm locked lladdr
If this option is specified,
.Xr vmd 8
will drop packets with altered sources addresses that do not match the
link layer addresses (MAC addresses) of the VM interfaces in this switch.
.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 be longer than 15 characters or end with a digit,
as described in
.Xr ifconfig 8 .
.It Cm interface Ar name
Set the
.Xr bridge 4 ,
.Xr switch 4
or
.Xr veb 4
network interface of this switch.
If the type is changed to
.Ar switch0 ,
it will be used for each following switch.
.It Cm rdomain Ar rdomainid
Set the routing domain of the switch and all of its VM interfaces to
.Ar rdomainid .
.It Cm up
Start the switch forwarding packets.
This is the default.
.It Cm down
Stop the switch from forwarding packets.
.El
.Sh FILES
.Bl -tag -width /etc/examples/vm.conf -compact
.It Pa /etc/vm.conf
.It Pa /etc/examples/vm.conf
.El
.Sh EXAMPLES
Create a new VM with 1GB memory, 1 network interface connected to
.Dq uplink ,
with one disk image
.Sq /home/joe/vm2-disk.img ,
owned by user
.Sq joe :
.Bd -literal -offset indent
vm "vm2.example.com" {
memory 1G
disk "/home/joe/vm2-disk.img"
interface { switch "uplink" }
owner joe
}
.Ed
.Pp
Create a new VM as an instance from
.Sq vm2.example.com :
.Bd -literal -offset indent
vm "vm2.example.com" instance "vm3.example.com" {
disk "/home/joe/vm3-disk.img"
}
.Ed
.Pp
Create the switch "uplink" with an additional physical network interface:
.Bd -literal -offset indent
switch "uplink" {
interface bridge0
}
.Ed
.Sh SEE ALSO
.Xr vmm 4 ,
.Xr MAKEDEV 8 ,
.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 .
.Sh CAVEATS
Each guest requires one
.Xr tap 4
device per assigned interface and one
.Xr pty 4
device.
Administrators may need to create additional devices using
.Xr MAKEDEV 8 .
|