emu: work around systemctl bad behavior

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
Robbie Harwood 2023-03-22 18:39:56 +00:00
parent 48cf39de05
commit 6a9365c88d
3 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Robbie Harwood <rharwood@redhat.com>
Date: Wed, 22 Mar 2023 14:19:43 -0400
Subject: [PATCH] emu/linux: work around systemctl kexec returning
Per systemctl(1), it "is asynchronous; it will return after the reboot
operation is enqueued, without waiting for it to complete". This
differs from kexec(8), which calls reboot(2) and therefore does not
return.
When not using fallback, this results in the confusing-but-harmless:
error trying to perform 'systemctl kexec': 0
Aborted. Press any key to exit.
on screen for a bit, followed by successful kexec.
To reduce the liklihood of hitting this case, add a delay on succesful
return. Ultimately, the systemd interface is racy: we can't avoid it
entirely unless we never fallback on success.
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/loader/emu/linux.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/grub-core/loader/emu/linux.c b/grub-core/loader/emu/linux.c
index 0cf378a376..7de3f7f861 100644
--- a/grub-core/loader/emu/linux.c
+++ b/grub-core/loader/emu/linux.c
@@ -74,6 +74,10 @@ grub_linux_boot (void)
(kexecute==1) ? "do-or-die" : "just-in-case");
rc = grub_util_exec (systemctl);
+ /* `systemctl kexec` is "asynchronous" and will return even on success. */
+ if (rc == 0)
+ grub_sleep (10);
+
if (kexecute == 1)
grub_fatal (N_("error trying to perform 'systemctl kexec': %d"), rc);

View file

@ -322,3 +322,4 @@ Patch0321: 0321-mm-Preallocate-some-space-when-adding-new-regions.patch
Patch0322: 0322-mm-Avoid-complex-heap-growth-math-in-hot-path.patch Patch0322: 0322-mm-Avoid-complex-heap-growth-math-in-hot-path.patch
Patch0323: 0323-hostdisk-work-around-proc-not-reporting-size.patch Patch0323: 0323-hostdisk-work-around-proc-not-reporting-size.patch
Patch0324: 0324-blscfg-check-for-mounted-boot-in-emu.patch Patch0324: 0324-blscfg-check-for-mounted-boot-in-emu.patch
Patch0325: 0325-emu-linux-work-around-systemctl-kexec-returning.patch

View file

@ -17,7 +17,7 @@
Name: grub2 Name: grub2
Epoch: 1 Epoch: 1
Version: 2.06 Version: 2.06
Release: 89%{?dist} Release: 90%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+ License: GPLv3+
URL: http://www.gnu.org/software/grub/ URL: http://www.gnu.org/software/grub/
@ -544,6 +544,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
%endif %endif
%changelog %changelog
* Wed Mar 22 2023 Robbie Harwood <rharwood@redhat.com> - 2.06-90
- emu: work around systemctl bad behavior
* Thu Mar 09 2023 Robbie Harwood <rharwood@redhat.com> - 2.06-89 * Thu Mar 09 2023 Robbie Harwood <rharwood@redhat.com> - 2.06-89
- emu: handle BLS /boot weirdness - emu: handle BLS /boot weirdness