can we get some interaction between halt/reboot and bhyve?
Paul Vixie
paul at redbarn.org
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.
*/
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
More information about the freebsd-virtualization
mailing list