From owner-freebsd-virtualization@FreeBSD.ORG Mon May 25 01:05:41 2015 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C51A4381 for ; Mon, 25 May 2015 01:05:41 +0000 (UTC) (envelope-from paul@redbarn.org) Received: from family.redbarn.org (family.redbarn.org [IPv6:2001:559:8000:cd::5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B1D7524B for ; Mon, 25 May 2015 01:05:41 +0000 (UTC) (envelope-from paul@redbarn.org) Received: from [IPv6:2001:559:8000:cb:c102:7d6:6720:f5ce] (unknown [IPv6:2001:559:8000:cb:c102:7d6:6720:f5ce]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by family.redbarn.org (Postfix) with ESMTPSA id C94BB1814C for ; Mon, 25 May 2015 00:10:17 +0000 (UTC) Message-ID: <5562755C.8090407@redbarn.org> Date: Sun, 24 May 2015 18:05:32 -0700 From: Paul Vixie User-Agent: Postbox 3.0.11 (Windows/20140602) MIME-Version: 1.0 To: "freebsd-virtualization@freebsd.org" Subject: can we get some interaction between halt/reboot and bhyve? X-Enigmail-Version: 1.2.3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 May 2015 01:05:41 -0000 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