diff options
author | kn <kn@cvs.openbsd.org> | 2020-05-23 13:06:34 +0000 |
---|---|---|
committer | kn <kn@cvs.openbsd.org> | 2020-05-23 13:06:34 +0000 |
commit | 5b4b5c7e07ab706324027a46520e0debc63fc4ef (patch) | |
tree | 0bc5421c3b5b60ab7862ed156c26c23ab4dbe167 | |
parent | 23e79d6c611ae5bd2a561a4efe55b9308e3ad5f7 (diff) |
Fail on duplicate vcpu, memory or iodevice parameters
Domains get to define their cores and memory only once unlike vnet, vdisk
and variable parameters of which it makes sense to have more than one;
iodevices are unique my design and may only be assigned once.
OK kettenis
-rw-r--r-- | usr.sbin/ldomctl/parse.y | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/usr.sbin/ldomctl/parse.y b/usr.sbin/ldomctl/parse.y index ec28d5d9f72..2d52336a826 100644 --- a/usr.sbin/ldomctl/parse.y +++ b/usr.sbin/ldomctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.18 2020/02/21 19:39:28 kn Exp $ */ +/* $OpenBSD: parse.y,v 1.19 2020/05/23 13:06:33 kn Exp $ */ /* * Copyright (c) 2012 Mark Kettenis <kettenis@openbsd.org> @@ -166,10 +166,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 vdisk_opts { @@ -192,10 +200,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 %s already" + " assigned: %s", $2); + YYERROR; + } + iodev = xmalloc(sizeof(struct iodev)); iodev->path = $2; SIMPLEQ_INSERT_TAIL(&domain->iodev_list, iodev, entry); - } + } ; vdisk_opts : { vdisk_opts_default(); } |