Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2015 18:05:32 -0700
From:      Paul Vixie <paul@redbarn.org>
To:        "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org>
Subject:   can we get some interaction between halt/reboot and bhyve?
Message-ID:  <5562755C.8090407@redbarn.org>

next in thread | raw e-mail | index | archive | help
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.
         */
        sleep(2);
        for (i = 0; i < 20; i++) {
                pageins = get_pageins();
                if (!nflag)
                        sync();
                sleep(3);
                if (get_pageins() == pageins)
                        break;
        }

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

-- 
Paul Vixie



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5562755C.8090407>