Hi,
A first stab at adding support for option `-B device' to vm.conf(5).
With the diff below, I'm able to add a dedicated VM to be used with
autoinstall(5):
vm "amd64-install" {
disable
boot $snapshots "bsd.rd"
disk $home "amd64.qcow2"
boot-device net
local interface
}
The name `boot-device' is of course up for debate. Also, should allow support
also be considered?
Comments? OK?
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/vmd/parse.y,v
retrieving revision 1.50
diff -u -p -r1.50 parse.y
--- parse.y 13 Feb 2019 22:57:08 -0000 1.50
+++ parse.y 28 Apr 2019 13:54:50 -0000
@@ -120,12 +120,13 @@ typedef struct {
%token INCLUDE ERROR
-%token ADD ALLOW BOOT CDROM DISABLE DISK DOWN ENABLE FORMAT GROUP INET6
-%token INSTANCE INTERFACE LLADDR LOCAL LOCKED MEMORY NIFS OWNER PATH PREFIX
-%token RDOMAIN SIZE SOCKET SWITCH UP VM VMID
+%token ADD ALLOW BOOT BOOTDEVICE CDROM DISABLE DISK DOWN ENABLE FORMAT GROUP
+%token INET6 INSTANCE INTERFACE LLADDR LOCAL LOCKED MEMORY NET NIFS OWNER
+%token PATH PREFIX RDOMAIN SIZE SOCKET SWITCH UP VM VMID
%token <v.number> NUMBER
%token <v.string> STRING
%type <v.lladdr> lladdr
+%type <v.number> bootdevice
%type <v.number> disable
%type <v.number> image_format
%type <v.number> local
@@ -456,6 +457,9 @@ vm_opts : disable {
}
vmc.vmc_flags |= VMOP_CREATE_KERNEL;
}
+ | BOOTDEVICE bootdevice {
+ vmc.vmc_bootdevice = $2;
+ }
| CDROM string {
if (vcp->vcp_cdrom[0] != '\0') {
yyerror("cdrom specified more than once");
@@ -703,6 +707,11 @@ disable : ENABLE { $$ =
0; }
| DISABLE { $$ = 1; }
;
+bootdevice : CDROM { $$ = VMBOOTDEV_CDROM; }
+ | DISK { $$ = VMBOOTDEV_DISK; }
+ | NET { $$ = VMBOOTDEV_NET; }
+ ;
+
optcomma : ','
|
;
@@ -755,6 +764,7 @@ lookup(char *s)
{ "add", ADD },
{ "allow", ALLOW },
{ "boot", BOOT },
+ { "boot-device", BOOTDEVICE },
{ "cdrom", CDROM },
{ "disable", DISABLE },
{ "disk", DISK },
@@ -772,6 +782,7 @@ lookup(char *s)
{ "local", LOCAL },
{ "locked", LOCKED },
{ "memory", MEMORY },
+ { "net", NET },
{ "owner", OWNER },
{ "prefix", PREFIX },
{ "rdomain", RDOMAIN },
Index: vm.conf.5
===================================================================
RCS file: /cvs/src/usr.sbin/vmd/vm.conf.5,v
retrieving revision 1.42
diff -u -p -r1.42 vm.conf.5
--- vm.conf.5 7 Mar 2019 18:54:06 -0000 1.42
+++ vm.conf.5 28 Apr 2019 13:54:50 -0000
@@ -144,6 +144,13 @@ See
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 of
+.Ar device
+which may be either
+.Ar cdrom , disk
+or
+.Ar net .
.It Cm cdrom Ar path
ISO image file.
.It Cm enable