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 <javierm@redhat.com>
Tested-by: Steven Haigh <netwiz@crc.id.au>
This commit is contained in:
Javier Martinez Canillas 2019-10-09 11:11:56 +02:00
parent 53711828a3
commit 3561ca9ef6
No known key found for this signature in database
GPG key ID: C751E590D63F3D69
2 changed files with 19 additions and 3 deletions

View file

@ -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

View file

@ -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 <javierm@redhat.com> - 2.02-82
- 99-grub-mkconfig: Disable BLS usage for Xen DomU guests
Resolves: rhbz#1703700
* Mon May 20 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-81
- Don't try to switch to a BLS config if GRUB_ENABLE_BLSCFG is already set