On Sun, Jan 05, 2020 at 07:09:46PM +0100, Klemens Nanni wrote:
> Domains get to define their cores and memory only once unlike the other
> parameters of which it makes sense to have more than one.
>
> $ cat dup.conf
> domain primary {
> vcpu 2
> vcpu 2
> }
> $ ldomctl init-system -n dup.conf ; echo $?
> 0
> $ ./obj/ldomctl init-system -n dup.conf
> dup.conf:3 duplicate vcpu option
>
> OK?
Now that checks for mandatory options are in, this somewhat completes
it at the other end.
Here's the same diff with an additional check for duplicate iodevices,
only that those must be globally unique (just like domain names).
OK?
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/ldomctl/parse.y,v
retrieving revision 1.15
diff -u -p -r1.15 parse.y
--- parse.y 9 Jan 2020 22:06:23 -0000 1.15
+++ parse.y 13 Jan 2020 11:44:45 -0000
@@ -156,10 +156,18 @@ domainoptsl : domainopts nl
;
domainopts : VCPU vcpu {
+ if (domain->vcpu) {
+ yyerror("duplicate vcpu option");
+ YYERROR;
+ }
domain->vcpu = $2.count;
domain->vcpu_stride = $2.stride;
}
| MEMORY memory {
+ if (domain->memory) {
+ yyerror("duplicate memory option");
+ YYERROR;
+ }
domain->memory = $2;
}
| VDISK STRING {
@@ -180,10 +188,19 @@ domainopts : VCPU vcpu {
SIMPLEQ_INSERT_TAIL(&domain->var_list, var, entry);
}
| IODEVICE STRING {
- struct iodev *iodev = xmalloc(sizeof(struct iodev));
+ struct domain *odomain;
+ struct iodev *iodev;
+ SIMPLEQ_FOREACH(odomain, &conf->domain_list, entry)
+ SIMPLEQ_FOREACH(iodev, &odomain->iodev_list,
entry)
+ if (strcmp(iodev->path, $2) == 0) {
+ yyerror("iodevice assigned"
+ " twice: %s", $2);
+ YYERROR;
+ }
+ iodev = xmalloc(sizeof(struct iodev));
iodev->path = $2;
SIMPLEQ_INSERT_TAIL(&domain->iodev_list, iodev, entry);
- }
+ }
;
vnet_opts : { vnet_opts_default(); }