libvirt and rebooting of a bhyve VM

Allan Jude allanjude at freebsd.org
Tue Aug 19 19:18:07 UTC 2014


On 2014-08-19 15:04, Craig Rodrigues wrote:
> On Tue, Aug 19, 2014 at 9:25 AM, Allan Jude <allanjude at freebsd.org> wrote:
>>
>> Yes, this revision adds the ability to 'reboot'. This does not exit
>> bhyve at all, so there is no exit level
>>
>> You can 'reboot' a bhyve externally using:
>> bhyvectl --force-reset --vm=xxx
>>
>> or force a poweroff with: bhyvectl --force-reset --vm=xxx
>>
>> SIGTERM simulates an ACPI shutdown
>>
>>
>> the bhyvectl --destroy is to clean up, the instance remains even after a
>> clean shutdown. In the past, it had to be destroyed and recreated to
>> start the VM again, although now with reboot support, that may not be
>> required.
> 
> Thanks for that information.  It's very useful.
> There doesn't seem to be a bhyvectl man page.  Do you have the
> bandwidth to write one up and check it into the tree?
> That would be very helpful.
> 
> I ran some experiments with bhyvectl --force-reset and
> --force-poweroff.  They work as expected.
> There doesn't seem to be a bhyvectl command which simulates ACPI shutdown.
> 
> If I have the name of the bhyve VM, is there a way that I can obtain
> the pid of the bhyve process which started
> the VM, so I can send it a SIGTERM, or do I need to keep track of that
> myself when starting the bhyve process?
> 

The name of the vm is in the title of the bhyve process, but yes, it
would be nice to expose the ACPI style shutdown via bhyvectl
--graceful-shutdown or something

> 
>>
>>
>> the bhyvectl --destroy is to clean up, the instance remains even after a
>> clean shutdown. In the past, it had to be destroyed and recreated to
>> start the VM again, although now with reboot support, that may not be
>> required.
> 
> You are right, calling bhyvectl --destroy does not seem to be required.
> I ran some experiments:
> 
> 
> DOESN'T WORK
> ==============
>     bhyvectl --destroy ......
>     bhyveload  .....
>     while true; do
>            byve ......
>            if [ $? -ne 0 ]; then
>                 break
>            fi
>    done
> 
> if I do a shutdown -r inside the VM, then when the VM reboots, I get:
> 
> Assertion failed: (error == 0), function fbsdrun_addcpu, file
> /usr/src/usr.sbin/bhyve/bhyverun.c, line 266.
> 
> 
> 
> 
> WORKING
> ========
>     bhyvectl --destroy ......
>     while true; do
>            bhyveload  .....
>            byve ......
>            if [ $? -ne 0 ]; then
>                 break
>            fi
>    done
> 
> 
> This combination seems to work fine.  I can do "shutdown -r" inside
> the VM, and it reboots fine.
> I can also do "shutdown -p", and the VM shuts down.
> 
> So I think vmrun.sh can be changed to accomodate this new behavior,
> and make it more clear
> to people writing scripts on top of bhyve.
> --
> Craig
> _______________________________________________
> freebsd-virtualization at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
> To unsubscribe, send any mail to "freebsd-virtualization-unsubscribe at freebsd.org"
> 

The question is, inside the while loop, after bhyve exits, does
/dev/vmm/<vmname> still exist?

Depending what you are doing, you may want to destroy it. If you
actually want to fully destroy and recreate the vm, you want to destroy
it. If you want to change the amount of ram or devices etc, you might
need to destroy it, etc.



-- 
Allan Jude

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-virtualization/attachments/20140819/5e1d5252/attachment.sig>


More information about the freebsd-virtualization mailing list