Blame SOURCES/0114-Don-t-assume-that-boot-commands-will-only-return-on-.patch

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