change reboot behaviour in vmd

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

change reboot behaviour in vmd

Claudio Jeker
So doing autoinstall with -B net is great but one thing I was missing is
changing the reboot behaviour of vmd to exit at a guest reboot.
I came up with this minimal diff that does the trick for me. Now maybe it
would be better to have a proper flag for this instead of overloading
vmc_bootdevice with it.

What is the preferred way of doing this?
--
:wq Claudio

Index: vmd.c
===================================================================
RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v
retrieving revision 1.107
diff -u -p -r1.107 vmd.c
--- vmd.c 4 Dec 2018 08:15:09 -0000 1.107
+++ vmd.c 4 Dec 2018 09:11:51 -0000
@@ -452,7 +452,8 @@ vmd_dispatch_vmm(int fd, struct privsep_
     __func__, vmr.vmr_id);
  break;
  }
- if (vmr.vmr_result != EAGAIN) {
+ if (vmr.vmr_result != EAGAIN ||
+    vm->vm_params.vmc_bootdevice) {
  if (vm->vm_from_config)
  vm_stop(vm, 0, __func__);
  else

Reply | Threaded
Open this post in threaded view
|

Re: change reboot behaviour in vmd

Carlos Cardenas
On Thu, Dec 06, 2018 at 10:33:24AM +0100, Claudio Jeker wrote:
> So doing autoinstall with -B net is great but one thing I was missing is
> changing the reboot behaviour of vmd to exit at a guest reboot.
> I came up with this minimal diff that does the trick for me. Now maybe it
> would be better to have a proper flag for this instead of overloading
> vmc_bootdevice with it.
>
> What is the preferred way of doing this?
> --
> :wq Claudio

I'm ok with this.

reyk@, what are your thoughts?

+--+
Carlos

>
> Index: vmd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v
> retrieving revision 1.107
> diff -u -p -r1.107 vmd.c
> --- vmd.c 4 Dec 2018 08:15:09 -0000 1.107
> +++ vmd.c 4 Dec 2018 09:11:51 -0000
> @@ -452,7 +452,8 @@ vmd_dispatch_vmm(int fd, struct privsep_
>      __func__, vmr.vmr_id);
>   break;
>   }
> - if (vmr.vmr_result != EAGAIN) {
> + if (vmr.vmr_result != EAGAIN ||
> +    vm->vm_params.vmc_bootdevice) {
>   if (vm->vm_from_config)
>   vm_stop(vm, 0, __func__);
>   else
>

Reply | Threaded
Open this post in threaded view
|

Re: change reboot behaviour in vmd

Claudio Jeker
In reply to this post by Claudio Jeker
On Thu, Dec 06, 2018 at 10:33:24AM +0100, Claudio Jeker wrote:

> So doing autoinstall with -B net is great but one thing I was missing is
> changing the reboot behaviour of vmd to exit at a guest reboot.
> I came up with this minimal diff that does the trick for me. Now maybe it
> would be better to have a proper flag for this instead of overloading
> vmc_bootdevice with it.
>
> What is the preferred way of doing this?
> --
> :wq Claudio
>
> Index: vmd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v
> retrieving revision 1.107
> diff -u -p -r1.107 vmd.c
> --- vmd.c 4 Dec 2018 08:15:09 -0000 1.107
> +++ vmd.c 4 Dec 2018 09:11:51 -0000
> @@ -452,7 +452,8 @@ vmd_dispatch_vmm(int fd, struct privsep_
>      __func__, vmr.vmr_id);
>   break;
>   }
> - if (vmr.vmr_result != EAGAIN) {
> + if (vmr.vmr_result != EAGAIN ||
> +    vm->vm_params.vmc_bootdevice) {
>   if (vm->vm_from_config)
>   vm_stop(vm, 0, __func__);
>   else
>

Here an update for vmctl.8 since this got committed.

--
:wq Claudio

Index: vmctl.8
===================================================================
RCS file: /cvs/src/usr.sbin/vmctl/vmctl.8,v
retrieving revision 1.57
diff -u -p -r1.57 vmctl.8
--- vmctl.8 7 Dec 2018 21:59:57 -0000 1.57
+++ vmctl.8 9 Dec 2018 12:23:44 -0000
@@ -168,6 +168,7 @@ to perform a PXE boot using the first ne
 Currently only supported when starting the VM with
 .Fl b
 specifying a kernel image.
+Additionally the VM will stop on guest reboot.
 .It Fl c
 Automatically connect to the VM console.
 .It Fl d Ar disk

Reply | Threaded
Open this post in threaded view
|

Re: change reboot behaviour in vmd

Reyk Floeter-2
In reply to this post by Carlos Cardenas
Sure, the bootdevice trick makes sense. Another trick could probably be to try to switch to the hard disk after first boot (install) but this would make the logic and config a bit ugly.

OK for the diff below.

The only thing that I’m a bit concerned about is that -B might turn a bit into a qemu-like getopt madness, especially if it would gain boot order or something like this. Please don’t complicate it further. But it still looks fine.

And -B should have options vm.conf. vm.conf should always have the same or more and not less options. The vm.conf grammar, on the other hand, allows to add more complex configurations.

Reyk

> Am 07.12.2018 um 20:55 schrieb Carlos Cardenas <[hidden email]>:
>
>> On Thu, Dec 06, 2018 at 10:33:24AM +0100, Claudio Jeker wrote:
>> So doing autoinstall with -B net is great but one thing I was missing is
>> changing the reboot behaviour of vmd to exit at a guest reboot.
>> I came up with this minimal diff that does the trick for me. Now maybe it
>> would be better to have a proper flag for this instead of overloading
>> vmc_bootdevice with it.
>>
>> What is the preferred way of doing this?
>> --
>> :wq Claudio
>
> I'm ok with this.
>
> reyk@, what are your thoughts?
>
> +--+
> Carlos
>
>>
>> Index: vmd.c
>> ===================================================================
>> RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v
>> retrieving revision 1.107
>> diff -u -p -r1.107 vmd.c
>> --- vmd.c    4 Dec 2018 08:15:09 -0000    1.107
>> +++ vmd.c    4 Dec 2018 09:11:51 -0000
>> @@ -452,7 +452,8 @@ vmd_dispatch_vmm(int fd, struct privsep_
>>                __func__, vmr.vmr_id);
>>            break;
>>        }
>> -        if (vmr.vmr_result != EAGAIN) {
>> +        if (vmr.vmr_result != EAGAIN ||
>> +            vm->vm_params.vmc_bootdevice) {
>>            if (vm->vm_from_config)
>>                vm_stop(vm, 0, __func__);
>>            else
>>

Reply | Threaded
Open this post in threaded view
|

Re: change reboot behaviour in vmd

Claudio Jeker
On Sun, Dec 09, 2018 at 01:54:50PM +0100, Reyk Floeter wrote:
> Sure, the bootdevice trick makes sense. Another trick could probably be to try to switch to the hard disk after first boot (install) but this would make the logic and config a bit ugly.
>
> OK for the diff below.
>
> The only thing that I’m a bit concerned about is that -B might turn a
> bit into a qemu-like getopt madness, especially if it would gain boot
> order or something like this. Please don’t complicate it further. But it
> still looks fine.

I called it bootdevice for a reason :)
In my opinion for a VM there is no reason to have fallback bootorders. You
boot from disk, net or cdrom and if it does not work you fix your VM
setup and restart. This is not like a real PC where changing boot order is
more tricky.
 
> And -B should have options vm.conf. vm.conf should always have the same
> or more and not less options. The vm.conf grammar, on the other hand,
> allows to add more complex configurations.

Adding bootdevice to vm.conf should be easy to do. I was just not sure if
it is really required since it is kind of a special case boot (caused by
manual intervention).
 

> Reyk
>
> > Am 07.12.2018 um 20:55 schrieb Carlos Cardenas <[hidden email]>:
> >
> >> On Thu, Dec 06, 2018 at 10:33:24AM +0100, Claudio Jeker wrote:
> >> So doing autoinstall with -B net is great but one thing I was missing is
> >> changing the reboot behaviour of vmd to exit at a guest reboot.
> >> I came up with this minimal diff that does the trick for me. Now maybe it
> >> would be better to have a proper flag for this instead of overloading
> >> vmc_bootdevice with it.
> >>
> >> What is the preferred way of doing this?
> >> --
> >> :wq Claudio
> >
> > I'm ok with this.
> >
> > reyk@, what are your thoughts?
> >
> > +--+
> > Carlos
> >
> >>
> >> Index: vmd.c
> >> ===================================================================
> >> RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v
> >> retrieving revision 1.107
> >> diff -u -p -r1.107 vmd.c
> >> --- vmd.c    4 Dec 2018 08:15:09 -0000    1.107
> >> +++ vmd.c    4 Dec 2018 09:11:51 -0000
> >> @@ -452,7 +452,8 @@ vmd_dispatch_vmm(int fd, struct privsep_
> >>                __func__, vmr.vmr_id);
> >>            break;
> >>        }
> >> -        if (vmr.vmr_result != EAGAIN) {
> >> +        if (vmr.vmr_result != EAGAIN ||
> >> +            vm->vm_params.vmc_bootdevice) {
> >>            if (vm->vm_from_config)
> >>                vm_stop(vm, 0, __func__);
> >>            else
> >>
>

--
:wq Claudio