can we get some interaction between halt/reboot and bhyve?

Paul Vixie paul at
Mon May 25 01:05:41 UTC 2015

bhyve interprets SIGTERM as an ACPI poweroff, and usually the VM will
shutdown very quickly. but it may not happen in five seconds, which is
all halt(8) (and reboot(8)) promises. the code for reboot and halt
(/usr/src/sbin/reboot/reboot.c) is shown below. what's the right way to
change this so that if there are 50 bhyve processes running and they are
ACPI powerdowning as fast as they can, then the halt or reboot of the
bare metal will wait for them?

        /* Send a SIGTERM first, a chance to save the buffers. */
        if (kill(-1, SIGTERM) == -1 && errno != ESRCH)
                err(1, "SIGTERM processes");

         * After the processes receive the signal, start the rest of the
         * buffers on their way.  Wait 5 seconds between the SIGTERM and
         * the SIGKILL to give everybody a chance. If there is a lot of
         * paging activity then wait longer, up to a maximum of approx
         * 60 seconds.
        for (i = 0; i < 20; i++) {
                pageins = get_pageins();
                if (!nflag)
                if (get_pageins() == pageins)

        for (i = 1;; ++i) {
                if (kill(-1, SIGKILL) == -1) {
                        if (errno == ESRCH)
                        goto restart;
                if (i > 5) {
                            "WARNING: some process(es) wouldn't die\n");
                (void)sleep(2 * i);

Paul Vixie

More information about the freebsd-virtualization mailing list