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 <[email protected]> --- 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
