ldomctl: reject vdisk, vnet and iodevice parameters for primary domain

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ldomctl: reject vdisk, vnet and iodevice parameters for primary domain

Klemens Nanni-2
In analogy to guest domains requiring vcpu, memory and at least one
bootable device (vdisk, vnet or iodevice), the primary domain must not
be configured with vdisk, vnet or iodevice parameters;  it does make
sense to provide virtual disks or interfaces to it and PCIe devices not
assigned to guest domains automatically end up in the primary domain.
ldom.conf(5) also documents those explicitly for guest domains only.

Feedback? OK?


===================================================================
RCS file: /cvs/src/usr.sbin/ldomctl/parse.y,v
retrieving revision 1.19
diff -u -p -r1.19 parse.y
--- parse.y 23 May 2020 13:06:33 -0000 1.19
+++ parse.y 23 May 2020 13:54:52 -0000
@@ -181,12 +181,22 @@ domainopts : VCPU vcpu {
  domain->memory = $2;
  }
  | VDISK STRING vdisk_opts {
+ if (strcmp(domain->name, "primary") == 0) {
+ yyerror("vdisk option invalid for primary"
+    " domain");
+ YYERROR;
+ }
  struct vdisk *vdisk = xmalloc(sizeof(struct vdisk));
  vdisk->path = $2;
  vdisk->devalias = $3.devalias;
  SIMPLEQ_INSERT_TAIL(&domain->vdisk_list, vdisk, entry);
  }
  | VNET vnet_opts {
+ if (strcmp(domain->name, "primary") == 0) {
+ yyerror("vnet option invalid for primary"
+    " domain");
+ YYERROR;
+ }
  struct vnet *vnet = xmalloc(sizeof(struct vnet));
  vnet->mac_addr = $2.mac_addr;
  vnet->mtu = $2.mtu;
@@ -200,6 +210,11 @@ domainopts : VCPU vcpu {
  SIMPLEQ_INSERT_TAIL(&domain->var_list, var, entry);
  }
  | IODEVICE STRING {
+ if (strcmp(domain->name, "primary") == 0) {
+ yyerror("iodevice option invalid for primary"
+    " domain");
+ YYERROR;
+ }
  struct domain *odomain;
  struct iodev *iodev;
  SIMPLEQ_FOREACH(odomain, &conf->domain_list, entry)