From nobody Wed Jun 10 04:01:11 2026 X-Original-To: dev-commits-src-all@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 4gZsX83Qmyz6gv5b for ; Wed, 10 Jun 2026 04:01:12 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gZsX80rLyz3wJp for ; Wed, 10 Jun 2026 04:01:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781064072; 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=zckJBWbMqahYmX9hWz/xf8OHOw+H5dpyu3EmcV3JCBc=; b=WpG0Q7wS01mbFFXy0uiOnYE/dtUHEBfyeLOjS/+Cw5TJigBPwZIZfuBg/fYKruWqW1fHUh ruU9bO91U2Oc+vABhfb3R6s5XPAomFCaiI4xCzQoic3E7woDLLVoH+0A1UWiRD9SjPmCGT nO4tryWYEbiW/5hxll3RT3HxrFC60oBA52l4syWHNxfaJolXn8eRcDjGzkfjF3KDtm7KRd CvRkmpPUz62PrGNVZ9qDA7F4zJK0dCoYUb9ZTpBpWy//6C27nY2zJtI9y/yCuEv+BOed+p RqqUXGey2EtS/VJYM+VrRaOz5coq8JMg6qkWnoCaNGBuOlo4OoQZIKDXNNd70Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781064072; a=rsa-sha256; cv=none; b=VTLMekowmWwRPQKDeVq5PnXC5MCsJ1IJ6ZBpVN1LmtDPdB3Qm42Fv13ODEkgLnPRxxse9o gazD0aqLfz+YlCTmMUbr9bYxlP6su0v4cO5xUAfK/LZ2F1xrZmLLkPwTwr8GdK90Xcv1hg xqWkAr0w5CheRdjLgM+NrMRnmkmFoHgZVhHeIiB0htvZNx+mHXEOXGq9V64zdpGu4fM29r xImLJNJqzvbHvD4T/NrQpctGcJ3Qwcq3qAS9TCMBvpUsPng/j/5xa/kCjxkjmBuQ4RM7WR pE11shk80tOEvrXrXUS76iGoG2yBo8DPxKdp4SRQD/RR36NaSROLhuX8ufcXXQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781064072; 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=zckJBWbMqahYmX9hWz/xf8OHOw+H5dpyu3EmcV3JCBc=; b=MzRFJs7ILWcqURGhWIlm0gDUhmoeAGOyfFx59ZzSnpu5f027ClKBk1gJ9rsW2ZwIbOPQ6n rOxXPGfqVEJjKzZsi2kVEe0H0LzR219srPnbzmtiZ6U+S5iHSNeshseZJDW+tiiWC0DSuz mTGioTNFvqgRrgrSvrdo49xqvW3sZSDiYUMnSDzyBcRFy3c/3NaSAsQ9fzBlk29xKut4KH JXcKDw2BUEFYBS80L/qEfwnB2+Gcwr2imFgc3J0t4BROEGQAdNWpn+CNLpPj1hUE1F1tvo Xm3HYmCD5ibxGQoKPtGuYdkV+J0bKNR3+06R/hpu68XfeQESPjJu76SadjvFxg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gZsX80926z14PX for ; Wed, 10 Jun 2026 04:01:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27a0e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 10 Jun 2026 04:01:11 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: bddfcbd9bbc6 - stable/14 - lualoader: add be-list and be-switch commands List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: bddfcbd9bbc68fe11ce53954b7f82584cd5ee40b Auto-Submitted: auto-generated Date: Wed, 10 Jun 2026 04:01:11 +0000 Message-Id: <6a28e187.27a0e.37b163a6@gitrepo.freebsd.org> The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=bddfcbd9bbc68fe11ce53954b7f82584cd5ee40b commit bddfcbd9bbc68fe11ce53954b7f82584cd5ee40b Author: Kyle Evans AuthorDate: 2026-06-04 13:57:16 +0000 Commit: Kyle Evans CommitDate: 2026-06-10 04:00:49 +0000 lualoader: add be-list and be-switch commands This is useful for driving BE changes from the loader command prompt, rather than having to use the menu. Note that the active carousel in the boot environment carousel doesn't currently reflect a switch in boot environments done this way- I'm considering this only a minor bug, as you probably can't or won't go back to the menu if you're using these commands. Reviewed by: imp (previous version) (cherry picked from commit c7ff706b31c22f10c2403869c46b443448da3e08) --- stand/lua/cli.lua | 23 +++++++++++++++++++++++ stand/lua/core.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ stand/lua/core.lua.8 | 17 ++++++++++++++++- stand/lua/menu.lua | 7 +------ stand/man/loader.8 | 15 ++++++++++++++- 5 files changed, 97 insertions(+), 8 deletions(-) diff --git a/stand/lua/cli.lua b/stand/lua/cli.lua index 6832da0a31a5..a405baba9468 100644 --- a/stand/lua/cli.lua +++ b/stand/lua/cli.lua @@ -172,6 +172,29 @@ cli["disable-module"] = function(...) setModule(argv[1], false) end +cli['be-list'] = function(...) + local _, argv = cli.arguments(...) + if #argv ~= 0 then + print("usage error: be-list") + return + end + + for _, bootenv in core.bootenvIter() do + print(bootenv) + end +end + +cli['be-switch'] = function(...) + local _, argv = cli.arguments(...) + if #argv == 0 then + print("usage error: be-switch beName") + return + end + + local env = argv[1] + core.switchBE(env) +end + cli["toggle-module"] = function(...) local _, argv = cli.arguments(...) if #argv == 0 then diff --git a/stand/lua/core.lua b/stand/lua/core.lua index 4091f446e1f1..16825d560094 100644 --- a/stand/lua/core.lua +++ b/stand/lua/core.lua @@ -312,6 +312,21 @@ function core.bootenvFilter(func) return oldf end +function core.bootenvIter() + local envs = core.bootenvList() + + if #envs ~= 0 then + local root = "zfs:" .. loader.getenv("zfs_be_root") .. "/" + + for idx, bespec in ipairs(envs) do + bespec = bespec:gsub("^" .. root, "") + envs[idx] = bespec + end + end + + return next, envs, nil +end + function core.bootenvList() local bootenv_count = tonumber(loader.getenv(bootenv_list .. "_count")) local bootenvs = {} @@ -565,6 +580,34 @@ function core.nextConsoleChoice() end end +function core.switchBE(env) + -- This branch will most likely be taken by the switch-be CLI command, + -- not by the menu. We could do some more validation that it's a valid + -- BE and let the user fully specify a zfs:be/dataset to avoid the + -- validation, but this isn't done at the moment. + if not env:match("^zfs:") then + local root = loader.getenv("zfs_be_root") + + if not root then + print("ZFS BE root not available -- no action taken") + return + end + + if not env:match("^" .. root) then + env = "zfs:" .. root .. "/" .. env + else + env = "zfs:" .. env + end + end + + loader.setenv("vfs.root.mountfrom", env) + loader.setenv("currdev", env .. ":") + config.reload() + if loader.getenv("kernelname") ~= nil then + loader.perform("unload") + end +end + -- The graphical-enabled loaders have unicode drawing character support. The -- text-only ones do not. We check the old and new bindings for term_drawrect as -- a proxy for unicode support, which will work on older boot loaders as well diff --git a/stand/lua/core.lua.8 b/stand/lua/core.lua.8 index 325320b2fce8..5cb2b46bd9d1 100644 --- a/stand/lua/core.lua.8 +++ b/stand/lua/core.lua.8 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 8, 2026 +.Dd June 4, 2026 .Dt CORE.LUA 8 .Os .Sh NAME @@ -175,6 +175,12 @@ returns true, then the boot environment is retained in the list. Otherwise, the boot environment is hidden. The old filter, if any, is returned to allow the caller to compose a filter on top of another filter. +.It Fn core.bootenvIter +Returns an iterator over the known boot environment list. +The returned boot environment names do not include the boot environmnt root, +which would need to be added back on from the +.Ev zfs_be_root +environment variable. .It Fn core.bootenvList Returns a table of boot environments, or an empty table. These will be picked up using the @@ -229,6 +235,15 @@ If there are no elements, this returns nil and nil. If there is one element, this returns the front element and an empty table. This will not operate on truly associative tables; numeric indices are required. +.It Fn core.switchBE beName +Switch to the requested +.Fa beName . +It may be either be formatted as a fully-qualified loader dataset path +.Dq zfs:pool/ROOT/beName , +or like one of +.Dq pool/ROOT/beName +or +.Dq beName . .It Fn core.loaderTooOld Returns true if the loader is too old. Specifically, this means, is the loader old enough to require one or more diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua index 2d92be3b7c6e..a5491aca3560 100644 --- a/stand/lua/menu.lua +++ b/stand/lua/menu.lua @@ -53,12 +53,7 @@ local function OnOff(str, value) end local function bootenvSet(env) - loader.setenv("vfs.root.mountfrom", env) - loader.setenv("currdev", env .. ":") - config.reload() - if loader.getenv("kernelname") ~= nil then - loader.perform("unload") - end + core.switchBE(env) end local function multiUserPrompt() diff --git a/stand/man/loader.8 b/stand/man/loader.8 index 484e0a7b300c..e35414049e23 100644 --- a/stand/man/loader.8 +++ b/stand/man/loader.8 @@ -26,7 +26,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd November 14, 2025 +.Dd June 4, 2026 .Dt LOADER 8 .Os .Sh NAME @@ -97,6 +97,19 @@ and .Pp .Bl -tag -width indent -compact .\" sort the following entries according to the second field +.It Ic be-list +Lists the boot environments that are visible to +.Nm . +The listed names may be used directly with +.Ic be-switch . +.It Ic be-switch Ar beName +Switch to the +.Ar beName +boot environment. +The +.Nm +configuration will be reloaded from the new root, and any previously loaded +kernel and modules will be immediately unloaded. .It Ic boot-conf Load the .Nm