From nobody Fri Sep 18 10:31:02 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hmTRq2Nshz6sGDW for ; Fri, 18 Sep 2026 10:31:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hmTRq0sTsz3MxD for ; Fri, 18 Sep 2026 10:31:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789727463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sRYBOOpYpTY9Q21cQOWNMtBXJOacqYA1/9ahehVJSyI=; b=N7xfoFt+ZTkKg9PcZAGlzUScYG+oY9Fi0vlhjuC1qX/O+OR++z/MYb+G0HkpoNuF5qNJ7G c1KqxeNJy8sg0AHhU89gLnlrDGftlM5SQFxBG/WoyeU/tVhK6tH/z2gBnG7CoKpfI+Jj0L Ps8XmwI6pJlGEUjeIDJG7Qj3es6r0iWB/wGT9bQbd2HllGK5QzVNV/gHpM+D4mVeC4lssl 0n21yVPl+AoGktWrv3x0GylL0rLDx0Qsah4eA9s1AdOnQ65bO2HHsYjpgiseabW/4+7l/5 M154zDHdyoT7vHwzAhvXm/M+iUKgCODO4vsJciffmpQyZH4tBwxuBnm0x0/iIA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789727463; b=Kor0/Qst1lcLkPgAusovuq/BvzPBK3rHFzrPXp1FXsUDO3i0K5Y5Jk4ao/ObqvWF0/uv0/ bpAaR7PYFROdV0MFhyH1apWKyiyhrkY8Dyght0ST5n88Vs0xdXar44YfHLKn0k48IFSxeD NOJfGvoEIg27Z7tdbzdQuIvDczGuJc3Y31FfT/BaTW1tz3GGjYl2yeTbGCNfxjP1AsABuy m3A4V0fWUNuS8qNnRBUii3zz5WIcciTONWy2y+yPyhW6dE5frBiV91xe+hS9RC+uSN22Y7 XNn5SQGDtTkKVVtXg4c/+oU0PUbICjqKmEjpNfTcCUXt3CzSwPYXX1fiIkNDKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789727463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sRYBOOpYpTY9Q21cQOWNMtBXJOacqYA1/9ahehVJSyI=; b=WK/vUqDQ0Rq/xk5552zi5J3/6FXcPLCtDqQd5hshkXe3YuJ64yVAGeQcS7t924Gvs+WIgj 66vmbeud3mEgSngtUC2EgsRda3dBiXBdoN5/36DyXRuy7JP15ou+17GxC+FQXXH8ZhE+zI NbKy/L8somXUdOvJco4FWhzF9uzlyKxtVp8H7pHSD8K2aW53Nxw6ijTd/lWHtmwPMHqchK 8XX+McoCCrJn/+RvD7cYjk5aNv4j7lpP27I6f3iVlgLod1q1tChnwHqv3dNWc9PLHnMJne /2H/LUPz1gl9WCurFn9ysTDtufhF2d1ZxCYx2H1TaU1FjnAXkO+crM/OOGuNvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hmTRp73ZnzFX5 for ; Fri, 18 Sep 2026 10:31:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 24da4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 18 Sep 2026 10:31:02 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bojan Novk=?utf-8?Q?ovi=C4=87?= Subject: git: ef821f9ba66a - main - bhyve: Add an option to prevent automatic restart in monitor mode List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bnovkov X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ef821f9ba66af44cd7a760451ecd706cd24b1ecb Auto-Submitted: auto-generated Date: Fri, 18 Sep 2026 10:31:02 +0000 Message-Id: <6aad12e6.24da4.3689205@gitrepo.freebsd.org> The branch main has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=ef821f9ba66af44cd7a760451ecd706cd24b1ecb commit ef821f9ba66af44cd7a760451ecd706cd24b1ecb Author: Bojan Novković AuthorDate: 2026-08-23 12:56:31 +0000 Commit: Bojan Novković CommitDate: 2026-09-18 10:28:32 +0000 bhyve: Add an option to prevent automatic restart in monitor mode Monitor mode will currently unconditionally restart the guest if it reboots, which can be incovenient in certain situations (e.g., resetting the guest after a panic). Address this by introducing a way to prevent automatic guest restarts in monitor mode. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D59123 --- usr.sbin/bhyve/aarch64/bhyverun_machdep.c | 9 +++++++-- usr.sbin/bhyve/amd64/bhyverun_machdep.c | 11 ++++++++--- usr.sbin/bhyve/bhyve.8 | 11 +++++++++-- usr.sbin/bhyve/bhyve_config.5 | 9 +++++++-- usr.sbin/bhyve/bhyverun.c | 7 ++++--- usr.sbin/bhyve/riscv/bhyverun_machdep.c | 9 +++++++-- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/usr.sbin/bhyve/aarch64/bhyverun_machdep.c b/usr.sbin/bhyve/aarch64/bhyverun_machdep.c index 1f13ad38dedb..311170c6952b 100644 --- a/usr.sbin/bhyve/aarch64/bhyverun_machdep.c +++ b/usr.sbin/bhyve/aarch64/bhyverun_machdep.c @@ -112,6 +112,7 @@ bhyve_usage(int code) " -k: key=value flat config file\n" " -M: monitor mode\n" " -m: memory size\n" + " -N: don't reboot while in monitor mode\n" " -o: set config 'var' to 'value'\n" " -p: pin 'vcpu' to 'hostcpu'\n" " -S: guest memory cannot be swapped\n" @@ -129,7 +130,7 @@ bhyve_optparse(int argc, char **argv) const char *optstr; int c; - optstr = "hCDMSWk:f:o:p:G:c:s:m:U:"; + optstr = "hCDMNSWk:f:o:p:G:c:s:m:U:"; while ((c = getopt(argc, argv, optstr)) != -1) { switch (c) { case 'c': @@ -154,7 +155,10 @@ bhyve_optparse(int argc, char **argv) set_config_value("memory.size", optarg); break; case 'M': - set_config_bool("monitor", true); + set_config_bool("monitor.enabled", true); + break; + case 'N': + set_config_bool("monitor.no_reboot", true); break; case 'o': if (!bhyve_parse_config_option(optarg)) { @@ -196,6 +200,7 @@ bhyve_optparse(int argc, char **argv) /* Handle backwards compatibility aliases in config options. */ bhyve_cfg_warn("virtio_msix", "virtio.msix"); + bhyve_cfg_warn("monitor", "monitor.enabled"); } void diff --git a/usr.sbin/bhyve/amd64/bhyverun_machdep.c b/usr.sbin/bhyve/amd64/bhyverun_machdep.c index ea1bad0d4eaa..3d498879cd58 100644 --- a/usr.sbin/bhyve/amd64/bhyverun_machdep.c +++ b/usr.sbin/bhyve/amd64/bhyverun_machdep.c @@ -98,6 +98,7 @@ bhyve_usage(int code) " -l: LPC device configuration\n" " -M: monitor mode\n" " -m: memory size\n" + " -N: don't reboot while in monitor mode\n" " -n: NUMA domain specification\n" " -o: set config 'var' to 'value'\n" " -P: vmexit from the guest on pause\n" @@ -125,9 +126,9 @@ bhyve_optparse(int argc, char **argv) int c; #ifdef BHYVE_SNAPSHOT - optstr = "aehuwxACDHIMPSWYk:f:o:p:G:c:s:m:n:l:K:U:r:"; + optstr = "aehuwxACDHIMNPSWYk:f:o:p:G:c:s:m:n:l:K:U:r:"; #else - optstr = "aehuwxACDHIMPSWYk:f:o:p:G:c:s:m:n:l:K:U:"; + optstr = "aehuwxACDHIMNPSWYk:f:o:p:G:c:s:m:n:l:K:U:"; #endif while ((c = getopt(argc, argv, optstr)) != -1) { switch (c) { @@ -203,7 +204,7 @@ bhyve_optparse(int argc, char **argv) set_config_value("memory.size", optarg); break; case 'M': - set_config_bool("monitor", true); + set_config_bool("monitor.enabled", true); break; case 'n': if (bhyve_numa_parse(optarg) != 0) @@ -214,6 +215,9 @@ bhyve_optparse(int argc, char **argv) if (!get_config_bool("acpi_tables")) errx(EX_USAGE, "NUMA emulation requires ACPI"); break; + case 'N': + set_config_bool("monitor.no_reboot", true); + break; case 'o': if (!bhyve_parse_config_option(optarg)) { errx(EX_USAGE, @@ -268,6 +272,7 @@ bhyve_optparse(int argc, char **argv) bhyve_cfg_warn("lpc.bootrom", "bootrom"); bhyve_cfg_warn("lpc.bootvars", "bootvars"); bhyve_cfg_warn("virtio_msix", "virtio.msix"); + bhyve_cfg_warn("monitor", "monitor.enabled"); } void diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8 index 2203f7dc17c7..a0b79e83d4ab 100644 --- a/usr.sbin/bhyve/bhyve.8 +++ b/usr.sbin/bhyve/bhyve.8 @@ -26,7 +26,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 5, 2026 +.Dd August 23, 2026 .Dt BHYVE 8 .Os .Sh NAME @@ -34,7 +34,7 @@ .Nd "run a guest operating system inside a virtual machine" .Sh SYNOPSIS .Nm -.Op Fl aCDeHhMPSuWwxY +.Op Fl aCDeHhMNPSuWwxY .Oo .Sm off .Fl c\~ @@ -345,6 +345,13 @@ See the flag in .Xr cpuset 1 for a list of valid NUMA memory allocation policies and their formats. +.It Fl N +Prevent monitor mode from automatically rebooting the virtual machine. +This option has no effect unless the +.Va monitor.enabled +configuration option is enabled or +.Fl M +was specified. .It Fl o Ar var Ns Cm = Ns Ar value Set the configuration variable .Ar var diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5 index aca87bbe08b1..37a740aec3ec 100644 --- a/usr.sbin/bhyve/bhyve_config.5 +++ b/usr.sbin/bhyve/bhyve_config.5 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 14, 2026 +.Dd September 17, 2026 .Dt BHYVE_CONFIG 5 .Os .Sh NAME @@ -236,12 +236,17 @@ to store its service files, such as the checkpoint socket. Overriding this path is useful when running .Xr bhyve 8 as an unprivileged user. -.It Va monitor Ta bool Ta false Ta +.It Va monitor.enabled Ta bool Ta false Ta Run the VM in .Ql monitor mode. More details are provided in .Xr bhyve 8 . +.It Va monitor.no_reboot Ta bool Ta false Ta +Prevent monitor mode from automatically rebooting the virtual machine. +This option has no effect unless the +.Va monitor.enabled +configuration option is enabled. .It Va vcpu.N.cpuset Ta string Ta none Ta Comma-separated host CPU IDs and ranges to which virtual CPU .Em N diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index aa1a28f406e0..eec5bf2fb629 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -752,7 +752,7 @@ do_open(const char *vmname) int error, flags; bool romboot, monitor; - monitor = get_config_bool_default("monitor", false); + monitor = get_config_bool_default("monitor.enabled", false); romboot = bootrom_boot(); /* @@ -943,7 +943,7 @@ main(int argc, char *argv[]) init_mem(guest_ncpus); init_bootrom(ctx); - if (get_config_bool_default("monitor", false)) { + if (get_config_bool_default("monitor.enabled", false)) { int monitor_pipe[2]; pid_t child; @@ -978,7 +978,8 @@ main(int argc, char *argv[]) exit(BHYVE_EXIT_ERROR); } else { status = WEXITSTATUS(status); - if (status != BHYVE_EXIT_RESET) + if (get_config_bool_default("monitor.no_reboot", false) || + status != BHYVE_EXIT_RESET) exit(status); } if (vm_reinit(ctx) != 0) { diff --git a/usr.sbin/bhyve/riscv/bhyverun_machdep.c b/usr.sbin/bhyve/riscv/bhyverun_machdep.c index b467ff9f52d9..50e68c958ab3 100644 --- a/usr.sbin/bhyve/riscv/bhyverun_machdep.c +++ b/usr.sbin/bhyve/riscv/bhyverun_machdep.c @@ -106,6 +106,7 @@ bhyve_usage(int code) " -k: key=value flat config file\n" " -M: monitor mode\n" " -m: memory size\n" + " -N: don't reboot while in monitor mode\n" " -o: set config 'var' to 'value'\n" " -p: pin 'vcpu' to 'hostcpu'\n" " -S: guest memory cannot be swapped\n" @@ -123,7 +124,7 @@ bhyve_optparse(int argc, char **argv) const char *optstr; int c; - optstr = "hCDMSWk:f:o:p:c:s:m:U:"; + optstr = "hCDMNSWk:f:o:p:c:s:m:U:"; while ((c = getopt(argc, argv, optstr)) != -1) { switch (c) { case 'c': @@ -142,11 +143,14 @@ bhyve_optparse(int argc, char **argv) bhyve_parse_simple_config_file(optarg); break; case 'M': - set_config_bool("monitor", true); + set_config_bool("monitor.enabled", true); break; case 'm': set_config_value("memory.size", optarg); break; + case 'N': + set_config_bool("monitor.no_reboot", true); + break; case 'o': if (!bhyve_parse_config_option(optarg)) { errx(EX_USAGE, @@ -187,6 +191,7 @@ bhyve_optparse(int argc, char **argv) /* Handle backwards compatibility aliases in config options. */ bhyve_cfg_warn("virtio_msix", "virtio.msix"); + bhyve_cfg_warn("monitor", "monitor.enabled"); } void