From 3561ca9ef6f8d162493e8da0b1029867f6240d50 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 9 Oct 2019 11:11:56 +0200 Subject: [PATCH] 99-grub-mkconfig: Disable BLS usage for Xen DomU guests GRUB is used to boot Xen Dom0 hosts so BLS is supported there, but PV and PVH Xen DomU guests are booted with pygrub that doesn't have BLS support. This means that only HVM Xen DomU guests can support BLS and others need a traditional GRUB configuration file that contains menuentry commands. So to make the GRUB config compatible with all Xen DomU guests, don't use the BLS snippets and instead call grub2-mkconfig to regenerate the config on each kernel install and removal. Even when HVM Xen DomU guests can support BLS, just disable for all DomU so the configuration is consistent across all Xen DomU guests variants. And also because even when an installation is made with HVM, this can be later changed to a DomU variant that uses pygrub and doesn't support BLS. Resolves: rhbz#1703700 Signed-off-by: Javier Martinez Canillas Tested-by: Steven Haigh --- 99-grub-mkconfig.install | 16 ++++++++++++++-- grub2.spec | 6 +++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/99-grub-mkconfig.install b/99-grub-mkconfig.install index e370899..5c5024c 100755 --- a/99-grub-mkconfig.install +++ b/99-grub-mkconfig.install @@ -4,10 +4,22 @@ if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then exit 0 fi +# A "control_d" string in /proc/xen/capabilities indicates that is a Xen Dom0 host. +[[ -e /sys/hypervisor/type ]] && read HV_TYPE < /sys/hypervisor/type +[[ -e /proc/xen/capabilities ]] && grep -q "control_d" /proc/xen/capabilities && XEN_DOM0=true + +if [[ $HV_TYPE = "xen" && $XEN_DOM0 != "true" ]]; then + if grep -q '^GRUB_ENABLE_BLSCFG="*true"*\s*$' /etc/default/grub; then + sed -i 's/^GRUB_ENABLE_BLSCFG=.*/GRUB_ENABLE_BLSCFG=false/' /etc/default/grub + fi +fi + ARCH=$(uname -m) -# Is only needed for ppc64* since we can't assume a BLS capable bootloader there -if [[ $ARCH != "ppc64" && $ARCH != "ppc64le" ]]; then +# A traditional grub configuration file needs to be generated only for ppc64le and +# Xen DomU guests since we can't assume that bootloaders will be BLS capable there. +if [[ $ARCH != "ppc64" && $ARCH != "ppc64le" ]] || + [[ $HV_TYPE = "xen" && $XEN_DOM0 = "true" ]]; then exit 0 fi diff --git a/grub2.spec b/grub2.spec index bcb3637..2210c39 100644 --- a/grub2.spec +++ b/grub2.spec @@ -7,7 +7,7 @@ Name: grub2 Epoch: 1 Version: 2.02 -Release: 81%{?dist} +Release: 82%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -476,6 +476,10 @@ rm -r /boot/grub2.tmp/ || : %endif %changelog +* Wed Oct 09 2019 Javier Martinez Canillas - 2.02-82 +- 99-grub-mkconfig: Disable BLS usage for Xen DomU guests + Resolves: rhbz#1703700 + * Mon May 20 2019 Javier Martinez Canillas - 2.02-81 - Don't try to switch to a BLS config if GRUB_ENABLE_BLSCFG is already set