Download raw body.
vmd(8): Fix no kernel or disk error
Jan Klemkow <jan@openbsd.org> writes:
> Hi,
>
> If you try to start vmd(8) with the follwiing vm.conf:
>
> vm "vm1" {
> disable
> boot "/bsd.rd"
> }
>
> you will run into the "no kernel or disk/cdrom specified" error.
> If your start an anonymous vm via
>
> # vmctl start -b /bsd.rd vm2
>
> It works fine.
>
> The configuration parser sets vmc->vmc_kernel to -1 and the flag
> VMOP_CREATE_KERNEL. The file is opens after vm_register(). In case of
> "vmctl start -b" the file is already opened before vm_register().
>
> But, the flag VMOP_CREATE_KERNEL was set in both cases before vm_register().
> Thus, we should check for the flag and not for the filedescriptor in this case.
> While here fix a wrong indentation, too.
>
> ok?
looks good, ok dv@.
>
> bye,
> Jan
>
> diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c
> index b4741dc74fc..cb9925496aa 100644
> --- a/usr.sbin/vmd/vmd.c
> +++ b/usr.sbin/vmd/vmd.c
> @@ -1212,8 +1212,8 @@ vm_register(struct privsep *ps, struct vmop_create_params *vmc,
> } else if (vmc->vmc_nnics > VM_MAX_NICS_PER_VM) {
> log_warnx("invalid number of interfaces");
> goto fail;
> - } else if (vmc->vmc_kernel == -1 && vmc->vmc_ndisks == 0
> - && strlen(vmc->vmc_cdrom) == 0) {
> + } else if ((vmc->vmc_flags & VMOP_CREATE_KERNEL) == 0 &&
> + vmc->vmc_ndisks == 0 && strlen(vmc->vmc_cdrom) == 0) {
> log_warnx("no kernel or disk/cdrom specified");
> goto fail;
> } else if (strlen(vmc->vmc_name) == 0) {
> @@ -1416,7 +1416,7 @@ vm_instance(struct privsep *ps, struct vmd_vm **vm_parent,
>
> /* kernel */
> if (vmc->vmc_kernel > -1 || ((*vm_parent)->vm_kernel_path != NULL &&
> - strnlen((*vm_parent)->vm_kernel_path, PATH_MAX) < PATH_MAX)) {
> + strnlen((*vm_parent)->vm_kernel_path, PATH_MAX) < PATH_MAX)) {
> if (vm_checkinsflag(vmc_parent, VMOP_CREATE_KERNEL, uid) != 0) {
> log_warnx("vm \"%s\" no permission to set boot image",
> name);
vmd(8): Fix no kernel or disk error