On Mon, Aug 12, 2019 at 06:20:23PM +0200, Anton Lindqvist wrote: > On Mon, Aug 12, 2019 at 02:52:46PM +0200, Klemens Nanni wrote: > > On Mon, Aug 12, 2019 at 02:14:42PM +0200, Anton Lindqvist wrote: > > > 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: > > I agree, but your wording implies the template might be there but vmd > > failed to find it. Also, "parent" and "template" seems too much; we > > have no other templates, so may I suggest one of the simpler > > > > invalid template > > template does not exist > > > > Updated diff changing the error message to invalid template. >
I'm ok with this. -ml > 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 12 Aug 2019 16:18:22 -0000 > @@ -249,6 +249,10 @@ vm_start_complete(struct imsg *imsg, int > "file"); > *ret = ENOENT; > break; > + case VMD_PARENT_INVALID: > + warnx("invalid 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 12 Aug 2019 16:18:22 -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 12 Aug 2019 16:18:22 -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" >