diff options
-rw-r--r-- | usr.sbin/vmmctl/main.c | 9 | ||||
-rw-r--r-- | usr.sbin/vmmctl/parse.y | 4 | ||||
-rw-r--r-- | usr.sbin/vmmctl/parser.h | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/usr.sbin/vmmctl/main.c b/usr.sbin/vmmctl/main.c index 4ac6884ac04..8606182ee65 100644 --- a/usr.sbin/vmmctl/main.c +++ b/usr.sbin/vmmctl/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.4 2015/11/27 09:11:39 reyk Exp $ */ +/* $OpenBSD: main.c,v 1.5 2015/12/01 20:52:44 halex Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -120,6 +120,7 @@ parse(int argc, char *argv[]) int i; memset(&res, 0, sizeof(res)); + res.nifs = -1; for (i = 0; ctl_commands[i].name != NULL; i++) { if (strncmp(ctl_commands[i].name, @@ -193,6 +194,10 @@ vmmaction(struct parse_result *res) errx(1, "too many disks"); else if (res->ndisks == 0) warnx("starting without disks"); + if (res->nifs == -1) + res->nifs = 0; + if (res->nifs == 0) + warnx("starting without network interfaces"); ret = start_vm(res->name, res->size, res->nifs, res->ndisks, res->disks, res->path); @@ -447,7 +452,7 @@ ctl_start(struct parse_result *res, int argc, char *argv[]) errx(1, "invalid memory size: %s", optarg); break; case 'i': - if (res->size) + if (res->nifs != -1) errx(1, "interfaces specified multiple times"); if (parse_ifs(res, optarg, 0) != 0) errx(1, "invalid interface count: %s", optarg); diff --git a/usr.sbin/vmmctl/parse.y b/usr.sbin/vmmctl/parse.y index f1bdaa38702..67f1bf96741 100644 --- a/usr.sbin/vmmctl/parse.y +++ b/usr.sbin/vmmctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.4 2015/11/27 09:11:39 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.5 2015/12/01 20:52:44 halex Exp $ */ /* * Copyright (c) 2007-2015 Reyk Floeter <reyk@openbsd.org> @@ -164,7 +164,7 @@ vm_opts : disable { res.path = $2; } | NIFS NUMBER { - if (res.nifs) { + if (res.nifs != -1) { yyerror("argument specified more than once"); YYERROR; } diff --git a/usr.sbin/vmmctl/parser.h b/usr.sbin/vmmctl/parser.h index b49e4e2b73b..73091d09d1b 100644 --- a/usr.sbin/vmmctl/parser.h +++ b/usr.sbin/vmmctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.3 2015/11/27 09:11:39 reyk Exp $ */ +/* $OpenBSD: parser.h,v 1.4 2015/12/01 20:52:44 halex Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -41,7 +41,7 @@ struct parse_result { char *name; char *path; long long size; - size_t nifs; + int nifs; size_t ndisks; char **disks; int disable; |