Understanding Bhyve shutdown

Nikos Vassiliadis nvass at gmx.com
Wed Apr 13 12:37:26 UTC 2016

Hi Roman,

On 04/13/16 13:55, Roman Bogorodskiy wrote:
>   Q1: Is there a way to know if a guest reacted to power button but
>       waiting for the bhyve process to terminate?

I just signal repeatedly $bhyve_pid until it's gone.

For what it's worth, I use this /etc/rc.shutdown.local:

# shutdown VMs
for sig in TERM KILL; do
         for f in 1 2 3 4 5 6 7 8 9 10; do
                 cmds=`killall -${sig} -q -s bhyve | sed 's/$/;/'`
                 test -z "$cmds" && exit
                 sh -c "$cmds"
                 sleep 1

When a VM is hang, it won't respond to TERM, so you might
want to use something like, 'for sig in TERM HUP KILL'.

It works ok in my experience and I do have some VMs running Java
which take a while to shutdown. Our VMs usually shut down within one
or two seconds, the Java ones need more but still within ten seconds
everything is gone. Experiment a bit and give it enough time to
shutdown gracefully and if it's still alive SIGHUP $bhyve_pid.


More information about the freebsd-virtualization mailing list