From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 04/10] bootchooser: use a globalvar scope for its bootargs
Date: Fri, 30 Oct 2026 11:54:02 +0100 [thread overview]
Message-ID: <20261030-boot-globalvar-stack-v1-4-a03803e1100c@pengutronix.de> (raw)
In-Reply-To: <20261030-boot-globalvar-stack-v1-0-a03803e1100c@pengutronix.de>
bootchooser passes the active target to the Kernel in
global.linux.bootargs.bootchooser and sets it to an empty value again
after booting failed. The variable is never removed though, so it stays
around with an empty value after the first boot attempt.
Use a globalvar scope instead, which removes the variable again and
also reverts any other boot related globalvars changed while booting
the target.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/bootchooser.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/common/bootchooser.c b/common/bootchooser.c
index 2a75dfdcc8..2049425ab3 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -6,6 +6,7 @@
#define pr_fmt(fmt) "bootchooser: " fmt
#include <bootchooser.h>
+#include <boot.h>
#include <environment.h>
#include <globalvar.h>
#include <magicvar.h>
@@ -846,6 +847,7 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain,
struct bootentries *entries;
struct bootentry *entry;
struct bootchooser_target *target;
+ struct globalvar_scope *scope = NULL;
int ret = 0;
entries = bootentries_alloc();
@@ -857,6 +859,8 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain,
goto out;
}
+ scope = boot_globalvar_scope_push();
+
system = basprintf("bootchooser.active=%s", target->name);
globalvar_add_simple("linux.bootargs.bootchooser", system);
free(system);
@@ -887,7 +891,7 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain,
*tryagain = 1;
out:
- globalvar_set_match("linux.bootargs.bootchooser", NULL);
+ globalvar_scope_pop(scope);
bootentries_free(entries);
--
2.47.3
next prev parent reply other threads:[~2026-10-30 10:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 10:53 [PATCH 00/10] boot: revert boot related globalvars after booting Sascha Hauer
2026-10-30 10:53 ` [PATCH 01/10] globalvar: add scopes to snapshot and restore globalvars Sascha Hauer
2026-10-30 10:54 ` [PATCH 02/10] bootm: revert globalvar changes in bootm_boot_cleanup() Sascha Hauer
2026-10-30 10:54 ` [PATCH 03/10] boot: revert globalvar changes after each boot entry Sascha Hauer
2026-10-30 10:54 ` Sascha Hauer [this message]
2026-10-30 10:54 ` [PATCH 05/10] test: py: add test for reverting globalvars after boot Sascha Hauer
2026-10-30 10:54 ` [PATCH 06/10] bootargs: remove unused linux_bootargs_overwrite() Sascha Hauer
2026-10-30 10:54 ` [PATCH 07/10] of: add watchdog bootarg directly instead of via a globalvar Sascha Hauer
2026-10-30 10:54 ` [PATCH 08/10] boot: drop the dyn infix from the bootentries bootargs variable Sascha Hauer
2026-10-30 10:54 ` [PATCH 09/10] defaultenv: don't use global.linux.bootargs.dyn.* in boot entries Sascha Hauer
2026-10-30 10:54 ` [PATCH 10/10] Documentation: migration-guides: describe reverting boot globalvars Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261030-boot-globalvar-stack-v1-4-a03803e1100c@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox