From 5b4b5c7e07ab706324027a46520e0debc63fc4ef Mon Sep 17 00:00:00 2001 From: kn Date: Sat, 23 May 2020 13:06:34 +0000 Subject: 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 --- usr.sbin/ldomctl/parse.y | 23 ++++++++++++++++++++--- 1 file 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 @@ -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(); } -- cgit v1.2.3