Hi, I recently fat fingered the vm template passed to vmctl and was greeted with the following error:
vmctl: start vm command failed: Operation not permitted I think we can be more specific in order to improve usability: vmctl: could not find specified parent template Comments? OK? Index: vmctl/vmctl.c =================================================================== RCS file: /cvs/src/usr.sbin/vmctl/vmctl.c,v retrieving revision 1.69 diff -u -p -r1.69 vmctl.c --- vmctl/vmctl.c 22 May 2019 16:19:21 -0000 1.69 +++ vmctl/vmctl.c 5 Aug 2019 15:11:38 -0000 @@ -249,6 +249,10 @@ vm_start_complete(struct imsg *imsg, int "file"); *ret = ENOENT; break; + case VMD_PARENT_INVALID: + warnx("could not find specified parent template"); + *ret = EINVAL; + break; default: errno = res; warn("start vm command failed"); Index: vmd/vmd.c =================================================================== RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v retrieving revision 1.114 diff -u -p -r1.114 vmd.c --- vmd/vmd.c 28 Jun 2019 13:32:51 -0000 1.114 +++ vmd/vmd.c 5 Aug 2019 15:11:38 -0000 @@ -1373,8 +1373,13 @@ vm_instance(struct privsep *ps, struct v /* return without error if the parent is NULL (nothing to inherit) */ if ((vmc->vmc_flags & VMOP_CREATE_INSTANCE) == 0 || - (*vm_parent = vm_getbyname(vmc->vmc_instance)) == NULL) + vmc->vmc_instance[0] == '\0') return (0); + + if ((*vm_parent = vm_getbyname(vmc->vmc_instance)) == NULL) { + errno = VMD_PARENT_INVALID; + return (-1); + } errno = 0; vmcp = &(*vm_parent)->vm_params; Index: vmd/vmd.h =================================================================== RCS file: /cvs/src/usr.sbin/vmd/vmd.h,v retrieving revision 1.95 diff -u -p -r1.95 vmd.h --- vmd/vmd.h 17 Jul 2019 05:51:07 -0000 1.95 +++ vmd/vmd.h 5 Aug 2019 15:11:38 -0000 @@ -72,6 +72,7 @@ #define VMD_VM_STOP_INVALID 1004 #define VMD_CDROM_MISSING 1005 #define VMD_CDROM_INVALID 1006 +#define VMD_PARENT_INVALID 1007 /* Image file signatures */ #define VM_MAGIC_QCOW "QFI\xfb"