Index | Thread | Search

From:
Ian Darwin <ian@darwinsys.com>
Subject:
Re: vmctl: show file path in error message
To:
tech@openbsd.org
Date:
Thu, 1 May 2025 20:01:24 -0400

Download raw body.

Thread
On 5/1/25 10:15 AM, Klemens Nanni wrote:
> I passed multiple '-d path/file' arguments to 'vmctl start' and it took me
> a while to find the typo amongst them since the error does not really help:
>
> 	vmctl: invalid disk path: No such file or directory
>
> This does:
> 	vmctl: invalid disk path: /home/kn/instal.img: No such file or directory
>
> OK?
Always in favor of actually-useful error messages. ok ian@
>
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmctl/main.c,v
> diff -u -p -r1.84 main.c
> --- main.c	21 Nov 2024 13:39:34 -0000	1.84
> +++ main.c	1 May 2025 14:12:53 -0000
> @@ -863,7 +863,7 @@ ctl_start(struct parse_result *res, int
>   			if (res->isopath)
>   				errx(1, "iso image specified multiple times");
>   			if (realpath(optarg, path) == NULL)
> -				err(1, "invalid iso image path");
> +				err(1, "invalid iso image path: %s", optarg);
>   			if ((res->isopath = strdup(path)) == NULL)
>   				errx(1, "strdup");
>   			break;
> @@ -886,7 +886,7 @@ ctl_start(struct parse_result *res, int
>   		case 'd':
>   			type = parse_disktype(optarg, &s);
>   			if (realpath(s, path) == NULL)
> -				err(1, "invalid disk path");
> +				err(1, "invalid disk path: %s", s);
>   			if (parse_disk(res, path, type) != 0)
>   				errx(1, "invalid disk: %s", optarg);
>   			break;
>