|
|
5593c8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
5593c8 |
From: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
5593c8 |
Date: Tue, 9 Apr 2019 13:12:40 +0200
|
|
|
5593c8 |
Subject: [PATCH] Don't assume that boot commands will only return on fail
|
|
|
5593c8 |
|
|
|
5593c8 |
While it's true that for most loaders the boot command never returns, it
|
|
|
5593c8 |
may be the case that it does. For example the GRUB emulator boot command
|
|
|
5593c8 |
calls to systemctl kexec which in turn does an asynchonous call to kexec.
|
|
|
5593c8 |
|
|
|
5593c8 |
So in this case GRUB will wrongly assume that the boot command fails and
|
|
|
5593c8 |
print a "Failed to boot both default and fallback entries" even when the
|
|
|
5593c8 |
kexec call later succeeds.
|
|
|
5593c8 |
|
|
|
5593c8 |
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
5593c8 |
---
|
|
|
5593c8 |
grub-core/normal/menu.c | 23 +++++++++++++----------
|
|
|
5593c8 |
1 file changed, 13 insertions(+), 10 deletions(-)
|
|
|
5593c8 |
|
|
|
5593c8 |
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
|
|
|
fd0330 |
index fe2e77a43e..ec0c92bade 100644
|
|
|
5593c8 |
--- a/grub-core/normal/menu.c
|
|
|
5593c8 |
+++ b/grub-core/normal/menu.c
|
|
|
5593c8 |
@@ -285,7 +285,7 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name)
|
|
|
5593c8 |
}
|
|
|
5593c8 |
|
|
|
5593c8 |
/* Run a menu entry. */
|
|
|
5593c8 |
-static void
|
|
|
5593c8 |
+static grub_err_t
|
|
|
5593c8 |
grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
|
|
|
5593c8 |
{
|
|
|
5593c8 |
grub_err_t err = GRUB_ERR_NONE;
|
|
|
5593c8 |
@@ -302,7 +302,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
|
|
|
5593c8 |
{
|
|
|
5593c8 |
grub_print_error ();
|
|
|
5593c8 |
grub_errno = GRUB_ERR_NONE;
|
|
|
5593c8 |
- return;
|
|
|
5593c8 |
+ return grub_errno;
|
|
|
5593c8 |
}
|
|
|
5593c8 |
|
|
|
5593c8 |
errs_before = grub_err_printed_errors;
|
|
|
5593c8 |
@@ -315,7 +315,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
|
|
|
5593c8 |
grub_env_context_open ();
|
|
|
5593c8 |
menu = grub_zalloc (sizeof (*menu));
|
|
|
5593c8 |
if (! menu)
|
|
|
5593c8 |
- return;
|
|
|
5593c8 |
+ return grub_errno;
|
|
|
5593c8 |
grub_env_set_menu (menu);
|
|
|
5593c8 |
if (auto_boot)
|
|
|
5593c8 |
grub_env_set ("timeout", "0");
|
|
|
5593c8 |
@@ -385,7 +385,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
|
|
|
5593c8 |
|
|
|
5593c8 |
if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
|
|
|
5593c8 |
/* Implicit execution of boot, only if something is loaded. */
|
|
|
5593c8 |
- grub_command_execute ("boot", 0, 0);
|
|
|
5593c8 |
+ err = grub_command_execute ("boot", 0, 0);
|
|
|
5593c8 |
|
|
|
5593c8 |
if (errs_before != grub_err_printed_errors)
|
|
|
5593c8 |
grub_wait_after_message ();
|
|
|
5593c8 |
@@ -408,6 +408,8 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
|
|
|
5593c8 |
else
|
|
|
5593c8 |
grub_env_unset ("default");
|
|
|
5593c8 |
grub_env_unset ("timeout");
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+ return err;
|
|
|
5593c8 |
}
|
|
|
5593c8 |
|
|
|
5593c8 |
/* Execute ENTRY from the menu MENU, falling back to entries specified
|
|
|
5593c8 |
@@ -422,10 +424,13 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
|
|
|
5593c8 |
void *callback_data)
|
|
|
5593c8 |
{
|
|
|
5593c8 |
int fallback_entry;
|
|
|
5593c8 |
+ grub_err_t err;
|
|
|
5593c8 |
|
|
|
5593c8 |
callback->notify_booting (entry, callback_data);
|
|
|
5593c8 |
|
|
|
5593c8 |
- grub_menu_execute_entry (entry, 1);
|
|
|
5593c8 |
+ err = grub_menu_execute_entry (entry, 1);
|
|
|
5593c8 |
+ if (err == GRUB_ERR_NONE)
|
|
|
5593c8 |
+ return;
|
|
|
5593c8 |
|
|
|
5593c8 |
/* Deal with fallback entries. */
|
|
|
5593c8 |
while ((fallback_entry = get_and_remove_first_entry_number (menu, "fallback"))
|
|
|
5593c8 |
@@ -436,11 +441,9 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
|
|
|
5593c8 |
|
|
|
5593c8 |
entry = grub_menu_get_entry (menu, fallback_entry);
|
|
|
5593c8 |
callback->notify_fallback (entry, callback_data);
|
|
|
5593c8 |
- grub_menu_execute_entry (entry, 1);
|
|
|
5593c8 |
- /* If the function call to execute the entry returns at all, then this is
|
|
|
5593c8 |
- taken to indicate a boot failure. For menu entries that do something
|
|
|
5593c8 |
- other than actually boot an operating system, this could assume
|
|
|
5593c8 |
- incorrectly that something failed. */
|
|
|
5593c8 |
+ err = grub_menu_execute_entry (entry, 1);
|
|
|
5593c8 |
+ if (err == GRUB_ERR_NONE)
|
|
|
5593c8 |
+ return;
|
|
|
5593c8 |
}
|
|
|
5593c8 |
|
|
|
5593c8 |
if (!autobooted)
|