|
|
e0db32 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
e0db32 |
From: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
e0db32 |
Date: Tue, 26 Feb 2019 20:11:27 +0100
|
|
|
e0db32 |
Subject: [PATCH] blscfg: fallback to default_kernelopts if BLS option field
|
|
|
e0db32 |
isn't set
|
|
|
e0db32 |
|
|
|
e0db32 |
If the $kernelopts variable isn't found, then the entry will fail to boot
|
|
|
e0db32 |
since there won't be a kernel command line params set. This makes the BLS
|
|
|
e0db32 |
configuration more fragile than a non-BLS one, since in that case it will
|
|
|
e0db32 |
boot even without a correct grubenv file.
|
|
|
e0db32 |
|
|
|
e0db32 |
So set a $default_kernelopts in the GRUB config file that will be used as
|
|
|
e0db32 |
a fallback if the value in the BLS options field can't be resolved.
|
|
|
e0db32 |
|
|
|
e0db32 |
Related: rhbz#1625124
|
|
|
e0db32 |
|
|
|
e0db32 |
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
e0db32 |
---
|
|
|
e0db32 |
grub-core/commands/blscfg.c | 7 +++++++
|
|
|
e0db32 |
util/grub.d/10_linux.in | 2 ++
|
|
|
e0db32 |
2 files changed, 9 insertions(+)
|
|
|
e0db32 |
|
|
|
e0db32 |
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
|
|
e0db32 |
index c432c6ba27a..11cc82b6f31 100644
|
|
|
e0db32 |
--- a/grub-core/commands/blscfg.c
|
|
|
e0db32 |
+++ b/grub-core/commands/blscfg.c
|
|
|
e0db32 |
@@ -628,6 +628,9 @@ static char *expand_val(char *value)
|
|
|
e0db32 |
char *end = value;
|
|
|
e0db32 |
bool is_var = false;
|
|
|
e0db32 |
|
|
|
e0db32 |
+ if (!value)
|
|
|
e0db32 |
+ return NULL;
|
|
|
e0db32 |
+
|
|
|
e0db32 |
while (*value) {
|
|
|
e0db32 |
if (*value == '$') {
|
|
|
e0db32 |
if (start != end) {
|
|
|
e0db32 |
@@ -701,6 +704,10 @@ static void create_entry (struct bls_entry *entry)
|
|
|
e0db32 |
|
|
|
e0db32 |
title = bls_get_val (entry, "title", NULL);
|
|
|
e0db32 |
options = expand_val (bls_get_val (entry, "options", NULL));
|
|
|
e0db32 |
+
|
|
|
e0db32 |
+ if (!options)
|
|
|
e0db32 |
+ options = expand_val (grub_env_get("default_kernelopts"));
|
|
|
e0db32 |
+
|
|
|
e0db32 |
initrds = bls_make_list (entry, "initrd", NULL);
|
|
|
e0db32 |
|
|
|
e0db32 |
hotkey = bls_get_val (entry, "grub_hotkey", NULL);
|
|
|
e0db32 |
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
|
|
e0db32 |
index da2992ac9f1..04fd8953f40 100644
|
|
|
e0db32 |
--- a/util/grub.d/10_linux.in
|
|
|
e0db32 |
+++ b/util/grub.d/10_linux.in
|
|
|
e0db32 |
@@ -158,6 +158,8 @@ linux_entry ()
|
|
|
e0db32 |
populate_header_warn
|
|
|
e0db32 |
|
|
|
e0db32 |
cat << EOF
|
|
|
e0db32 |
+set default_kernelopts="root=${linux_root_device_thisversion} ro ${args}"
|
|
|
e0db32 |
+
|
|
|
e0db32 |
insmod blscfg
|
|
|
e0db32 |
blscfg
|
|
|
e0db32 |
if [ -s \$prefix/grubenv ]; then
|