On Sat, Oct 26, 2019 at 12:57:56AM +0200, Klemens Nanni wrote:
> It makes no sense to allow zero interfaces; either a positive count is
> given or -i is omitted entirely. vm.conf(5) does not allow interface
> configuration that results in zero interfaces either.
>
> $ doas vmctl start -Li0 -b ~/bsd.rd foo
> vmctl: starting without disks
> vmctl: started vm 6 successfully, tty /dev/ttyph
>
> Diff below raises the minimum to one and tells more about invalid counts
> with the usual strtonum(3) idiom:
>
> $ doas vmctl start -Li-1 -b ~/bsd.rd foo
> vmctl: invalid count "-1": too small
> vmctl: invalid interface count: -1
> $ doas ./obj/vmctl start -Li0 -b ~/bsd.rd foo
> vmctl: count is too small: 0
> vmctl: invalid interface count: 0
>
> Those duplicate errors aren't easily merged without breaking consistency
> with how all the command line flags are passed, so I did nothing about
> this.
>
> OK?
>
>
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmctl/main.c,v
> retrieving revision 1.58
> diff -u -p -r1.58 main.c
> --- main.c 23 Aug 2019 07:55:20 -0000 1.58
> +++ main.c 25 Oct 2019 22:48:49 -0000
> @@ -373,9 +373,9 @@ parse_ifs(struct parse_result *res, char
> const char *error;
>
> if (word != NULL) {
> - val = strtonum(word, 0, INT_MAX, &error);
> + val = strtonum(word, 1, INT_MAX, &error);
> if (error != NULL) {
> - warnx("invalid count \"%s\": %s", word, error);
> + warnx("count is %s: %s", error, word);
> return (-1);
> }
> }
>
ok mlarkin@ if you are still looking to do this.