From 55abb960d633c6d9f959eef5b766daa4402bb314 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 9 Feb 2025 17:35:14 +0000 Subject: [PATCH] Update common submodule Pulls in the following fix: commit 38315604596ac747e44e38db79496610efee49f8 Author: Richard W.M. Jones Date: Thu Feb 6 08:04:38 2025 +0000 mldrivers/linux_bootloaders.ml: Don't overwrite EFI grub2 wrapper Fedora 34+ and RHEL 9.0+ unified BIOS and UEFI grub configuration into a single file. This leaves /boot/efi/EFI//grub.cfg as a so-called "wrapper" which just loads the real grub2 configuration at /boot/grub2/grub.cfg. Running '/sbin/grub2-mkconfig -o /boot/efi/EFI//grub.cfg' overwrites the wrapper instead of the real configuration file. RHEL 9.5 added a hard error if you try to do this, which broke virt-v2v. The error message was: commandrvf: /sbin/grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg Running `grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg' will overwrite the GRUB wrapper. Please run `grub2-mkconfig -o /boot/grub2/grub.cfg' instead to update grub.cfg. Try to detect this situation and substitute the real grub configuration file instead. Reported-by: Robert Knipp, Fabian Deutsch Thanks: Nijin Ashok, Marta Lewandowska Fixes: https://issues.redhat.com/browse/RHEL-77989 Related: https://issues.redhat.com/browse/RHEL-32099 Related: https://fedoraproject.org/wiki/Changes/UnifyGrubConfig Fixes: https://issues.redhat.com/browse/RHEL-77989 Related: https://issues.redhat.com/browse/RHEL-32099 (cherry picked from commit 17610d1c9b37424fec55c39fbf83c971a843f45f) (cherry picked from commit 60785259a8bea65663da270b25ea6f46be42aa0f) --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Submodule common 94619ded..084ea740: diff --git a/common/mldrivers/linux_bootloaders.ml b/common/mldrivers/linux_bootloaders.ml index 91c5ab9e..25afcc59 100644 --- a/common/mldrivers/linux_bootloaders.ml +++ b/common/mldrivers/linux_bootloaders.ml @@ -410,6 +410,28 @@ let detect_bootloader (g : G.guestfs) root i_firmware = in loop paths in + (* If we found a grub2 boot config called /boot/efi/EFI//grub.cfg + * check if it's a "wrapper" that redirects to /boot/grub2/grub.cfg. + * This is needed for Fedora 34+ and RHEL 9.0+. See: + * https://issues.redhat.com/browse/RHEL-32099 + * https://issues.redhat.com/browse/RHEL-77989 + * https://github.com/libguestfs/libguestfs-common/pull/6 + *) + let grub_config = + match typ with + | Grub1 -> grub_config + | Grub2 -> + let grub2_efi_rex = PCRE.compile "^/boot/efi/EFI/.*/grub.cfg$" in + let grub2_real = "/boot/grub2/grub.cfg" in + + if PCRE.matches grub2_efi_rex grub_config && + (* does it look like the "wrapper"? *) + g#grep "configfile \\$prefix/grub\\.cfg" grub_config <> [||] && + g#exists grub2_real then + grub2_real + else + grub_config in + let bl = match typ with | Grub1 -> new bootloader_grub1 g root grub_config