SHA256
1
0
forked from pool/grub2
grub2/grub2-efi-xen-chainload.patch

167 lines
5.2 KiB
Diff
Raw Normal View History

Accepting request 295632 from home:michael-chang:sle-12-merge - Merge changes from SLE12 - Do not pass root= when root is on nfs (bnc#894374) * modified grub2-pass-corret-root-for-nfsroot.patch * modified grub2-secureboot-provide-linuxefi-config.patch * modified grub2-secureboot-use-linuxefi-on-uefi.patch - Fix xen pvops kernel not appear on menu (bnc#895286) * modified grub2-fix-menu-in-xen-host-server.patch - Workaround grub2-once (bnc#892358) * added grub2-btrfs-workaround-grub2-once.patch * added grub2-once.service * modified grub2-once - Fix busy-loop and hang while network booting (bnc#870613) * added grub2-netboot-hang.patch - Add warning in grubenv file about editing it directly (bnc#887008) * added grub2-editenv-add-warning-message.patch - Fix broken graphics with efifb on QEMU/KVM and nomodeset (bnc#884558) * added grub2-efi-disable-video-cirrus-and-bochus.patch - Disable video support on Power (bnc#877142) * added grub2-ppc64le-disable-video.patch - Track occupied memory so it can be released on exit (bnc#885026) * added grub2-ppc64le-memory-map.patch - Fix grub.xen config searching path on boot partition (bnc#884828) - Add linux16 and initrd16 to grub.xen (bnc#884830) * added grub2-xen-linux16.patch - VLAN tag support (fate#315753) * added 0001-Add-bootargs-parser-for-open-firmware.patch * added 0002-Add-Virtual-LAN-support.patch - Use chainloader to boot xen.efi under UEFI (bnc#871857) * added grub2-efi-xen-chainload.patch - Use device part of chainloader target, if present (bnc#871857) OBS-URL: https://build.opensuse.org/request/show/295632 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=148
2015-04-13 19:58:16 +02:00
From: Raymund Will <rw@suse.com>
Subject: Use chainloader to boot xen.efi under UEFI.
References: bnc#871857, bnc#879148
Patch-Mainline: no
As XEN on SLE12 is not multiboot2 ready, some very dirty hacking
is necessary to boot via xen.efi and separate configfile snippets
(as done in SLE11SP3 secureboot).
To that end said configfile snippets, xen efi-binaries, kernels and initrds
need to copied to the EFI system partition during 'grub2-mkconfig'!
V0:
- first, somewhat fragile version, without any sort of cleanup for ESP.
V1:
- add missing whitespace. (bnc879148)
V2:
- second, much less fragile version, using only one config file per
XEN hypervisor version with sections for different kernels, avoiding
useless duplicates for sym-linked hypervisors. and removing previously
installed files from ESP.
---
util/grub.d/20_linux_xen.in | 88 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 86 insertions(+), 2 deletions(-)
Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
===================================================================
--- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in
+++ grub-2.02~beta2/util/grub.d/20_linux_xen.in
Accepting request 295632 from home:michael-chang:sle-12-merge - Merge changes from SLE12 - Do not pass root= when root is on nfs (bnc#894374) * modified grub2-pass-corret-root-for-nfsroot.patch * modified grub2-secureboot-provide-linuxefi-config.patch * modified grub2-secureboot-use-linuxefi-on-uefi.patch - Fix xen pvops kernel not appear on menu (bnc#895286) * modified grub2-fix-menu-in-xen-host-server.patch - Workaround grub2-once (bnc#892358) * added grub2-btrfs-workaround-grub2-once.patch * added grub2-once.service * modified grub2-once - Fix busy-loop and hang while network booting (bnc#870613) * added grub2-netboot-hang.patch - Add warning in grubenv file about editing it directly (bnc#887008) * added grub2-editenv-add-warning-message.patch - Fix broken graphics with efifb on QEMU/KVM and nomodeset (bnc#884558) * added grub2-efi-disable-video-cirrus-and-bochus.patch - Disable video support on Power (bnc#877142) * added grub2-ppc64le-disable-video.patch - Track occupied memory so it can be released on exit (bnc#885026) * added grub2-ppc64le-memory-map.patch - Fix grub.xen config searching path on boot partition (bnc#884828) - Add linux16 and initrd16 to grub.xen (bnc#884830) * added grub2-xen-linux16.patch - VLAN tag support (fate#315753) * added 0001-Add-bootargs-parser-for-open-firmware.patch * added 0002-Add-Virtual-LAN-support.patch - Use chainloader to boot xen.efi under UEFI (bnc#871857) * added grub2-efi-xen-chainload.patch - Use device part of chainloader target, if present (bnc#871857) OBS-URL: https://build.opensuse.org/request/show/295632 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=148
2015-04-13 19:58:16 +02:00
@@ -21,6 +21,8 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
+ME=$(basename $0)
+
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
export TEXTDOMAIN=@PACKAGE@
@@ -36,9 +38,11 @@ CLASS="--class gnu-linux --class gnu --c
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
+ os=linux
else
OS="${GRUB_DISTRIBUTOR}"
- CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
+ os="$(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1)"
+ CLASS="--class ${os} ${CLASS}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
@@ -81,6 +85,31 @@ esac
title_correction_code=
+if [ -d /sys/firmware/efi ]; then
+ is_efi=true
+ err_msg=""
+ efi_dir="/boot/efi/efi/${os}"
+ grub_dir=/boot/@PACKAGE@
+ xen_dir=/usr/lib64/efi
+ for d in $grub_dir $efi_dir $xen_dir; do
+ [ ! -d "$d" ] || continue
+ err_msg="${err_msg}$ME: Essential directory '$d' not found!\n"
+ done
+ if ! [ -d "$efi_dir" -a -d "$grub_dir" -a -d "$xen_dir" ]; then
+ err_msg="${err_msg}$ME: XEN configuration skipped!\n"
+ else
+ rm -f $grub_dir/xen*.cfg
+ if [ -s $efi_dir/grub.xen-files ]; then
+ for f in $(sort $efi_dir/grub.xen-files| uniq); do
+ rm -f $efi_dir/$f
+ done
+ : > $efi_dir/grub.xen-files
+ fi
+ fi
+else
+ is_efi=false
+fi
+
linux_entry ()
{
os="$1"
@@ -118,6 +147,40 @@ linux_entry ()
Accepting request 295632 from home:michael-chang:sle-12-merge - Merge changes from SLE12 - Do not pass root= when root is on nfs (bnc#894374) * modified grub2-pass-corret-root-for-nfsroot.patch * modified grub2-secureboot-provide-linuxefi-config.patch * modified grub2-secureboot-use-linuxefi-on-uefi.patch - Fix xen pvops kernel not appear on menu (bnc#895286) * modified grub2-fix-menu-in-xen-host-server.patch - Workaround grub2-once (bnc#892358) * added grub2-btrfs-workaround-grub2-once.patch * added grub2-once.service * modified grub2-once - Fix busy-loop and hang while network booting (bnc#870613) * added grub2-netboot-hang.patch - Add warning in grubenv file about editing it directly (bnc#887008) * added grub2-editenv-add-warning-message.patch - Fix broken graphics with efifb on QEMU/KVM and nomodeset (bnc#884558) * added grub2-efi-disable-video-cirrus-and-bochus.patch - Disable video support on Power (bnc#877142) * added grub2-ppc64le-disable-video.patch - Track occupied memory so it can be released on exit (bnc#885026) * added grub2-ppc64le-memory-map.patch - Fix grub.xen config searching path on boot partition (bnc#884828) - Add linux16 and initrd16 to grub.xen (bnc#884830) * added grub2-xen-linux16.patch - VLAN tag support (fate#315753) * added 0001-Add-bootargs-parser-for-open-firmware.patch * added 0002-Add-Virtual-LAN-support.patch - Use chainloader to boot xen.efi under UEFI (bnc#871857) * added grub2-efi-xen-chainload.patch - Use device part of chainloader target, if present (bnc#871857) OBS-URL: https://build.opensuse.org/request/show/295632 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=148
2015-04-13 19:58:16 +02:00
save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/"
fi
+ if $is_efi; then
+ xen_cfg=${xen_basename/.efi/.cfg}
+ if [ "$section_count" = 0 ]; then
+ cat <<-EOF > $grub_dir/$xen_cfg
+ # disclaimer
+ [global]
+ #default=
+ EOF
+ fi
+ section_count=$(expr $section_count + 1)
+ if [ x$type != xrecovery ] ; then
+ section="config.$section_count"
+ else
+ section="failsafe.$section_count"
+ fi
+ cat <<-EOF >> $grub_dir/$xen_cfg
+
+ [$section]
+ options=${xen_args}
+ kernel=${basename} root=${linux_root_device_thisversion} ${args}
+ ramdisk=${initrd}
+ EOF
+ message="$(gettext_printf "Loading Xen %s with Linux %s ..." ${xen_version} ${version})"
+ sed "s/^/$submenu_indentation/" <<-EOF
+ echo '$(echo "$message" | grub_quote)'
+ chainloader \$cmdpath/${xen_basename} ${xen_basename} $section
+ }
+ EOF
+ for f in ${grub_dir}/$xen_cfg ${xen_dir}/${xen_basename} ${rel_dirname}/${basename} ${rel_dirname}/${initrd}; do
+ cp --preserve=timestamps $f $efi_dir
+ echo $(basename $f) >> $efi_dir/grub.xen-files
+ done
+ return
+ fi
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
fi
@@ -225,6 +288,24 @@ while [ "x${xen_list}" != "x" ] ; do
Accepting request 295632 from home:michael-chang:sle-12-merge - Merge changes from SLE12 - Do not pass root= when root is on nfs (bnc#894374) * modified grub2-pass-corret-root-for-nfsroot.patch * modified grub2-secureboot-provide-linuxefi-config.patch * modified grub2-secureboot-use-linuxefi-on-uefi.patch - Fix xen pvops kernel not appear on menu (bnc#895286) * modified grub2-fix-menu-in-xen-host-server.patch - Workaround grub2-once (bnc#892358) * added grub2-btrfs-workaround-grub2-once.patch * added grub2-once.service * modified grub2-once - Fix busy-loop and hang while network booting (bnc#870613) * added grub2-netboot-hang.patch - Add warning in grubenv file about editing it directly (bnc#887008) * added grub2-editenv-add-warning-message.patch - Fix broken graphics with efifb on QEMU/KVM and nomodeset (bnc#884558) * added grub2-efi-disable-video-cirrus-and-bochus.patch - Disable video support on Power (bnc#877142) * added grub2-ppc64le-disable-video.patch - Track occupied memory so it can be released on exit (bnc#885026) * added grub2-ppc64le-memory-map.patch - Fix grub.xen config searching path on boot partition (bnc#884828) - Add linux16 and initrd16 to grub.xen (bnc#884830) * added grub2-xen-linux16.patch - VLAN tag support (fate#315753) * added 0001-Add-bootargs-parser-for-open-firmware.patch * added 0002-Add-Virtual-LAN-support.patch - Use chainloader to boot xen.efi under UEFI (bnc#871857) * added grub2-efi-xen-chainload.patch - Use device part of chainloader target, if present (bnc#871857) OBS-URL: https://build.opensuse.org/request/show/295632 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=148
2015-04-13 19:58:16 +02:00
xen_dirname=`dirname ${current_xen}`
rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
xen_version=`echo $xen_basename | sed -e "s,.gz$,,g;s,^xen-,,g"`
+ xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`
+ if $is_efi; then
+ xen_basename=${xen_basename/.gz/.efi}
+ if ! [ -f ${xen_dir}/${xen_basename} ]; then
+ echo "Skip missing hypervisor $xen_dir/$xen_basename" >&2
+ continue
+ elif [ -L ${xen_dir}/${xen_basename} ]; then
+ xen_target=$(basename $(readlink -e ${xen_dir}/${xen_basename}))
+ if [ -f ${efi_dir}/${xen_target} ]; then
+ echo "Skip duplicate $xen_dir/$xen_basename for $xen_target" >&2
+ continue
+ fi
+ elif [ -n "$err_msg" ]; then
+ break
+ fi
+ gettext_printf "Found hypervisor: %s\n" "$current_xen" >&2
+ section_count=0
+ fi
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
@@ -289,7 +370,6 @@ while [ "x${xen_list}" != "x" ] ; do
Accepting request 295632 from home:michael-chang:sle-12-merge - Merge changes from SLE12 - Do not pass root= when root is on nfs (bnc#894374) * modified grub2-pass-corret-root-for-nfsroot.patch * modified grub2-secureboot-provide-linuxefi-config.patch * modified grub2-secureboot-use-linuxefi-on-uefi.patch - Fix xen pvops kernel not appear on menu (bnc#895286) * modified grub2-fix-menu-in-xen-host-server.patch - Workaround grub2-once (bnc#892358) * added grub2-btrfs-workaround-grub2-once.patch * added grub2-once.service * modified grub2-once - Fix busy-loop and hang while network booting (bnc#870613) * added grub2-netboot-hang.patch - Add warning in grubenv file about editing it directly (bnc#887008) * added grub2-editenv-add-warning-message.patch - Fix broken graphics with efifb on QEMU/KVM and nomodeset (bnc#884558) * added grub2-efi-disable-video-cirrus-and-bochus.patch - Disable video support on Power (bnc#877142) * added grub2-ppc64le-disable-video.patch - Track occupied memory so it can be released on exit (bnc#885026) * added grub2-ppc64le-memory-map.patch - Fix grub.xen config searching path on boot partition (bnc#884828) - Add linux16 and initrd16 to grub.xen (bnc#884830) * added grub2-xen-linux16.patch - VLAN tag support (fate#315753) * added 0001-Add-bootargs-parser-for-open-firmware.patch * added 0002-Add-Virtual-LAN-support.patch - Use chainloader to boot xen.efi under UEFI (bnc#871857) * added grub2-efi-xen-chainload.patch - Use device part of chainloader target, if present (bnc#871857) OBS-URL: https://build.opensuse.org/request/show/295632 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=148
2015-04-13 19:58:16 +02:00
if [ x"$is_top_level" != xtrue ]; then
echo ' }'
fi
- xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`
done
# If at least one kernel was found, then we need to
@@ -299,3 +379,7 @@ if [ x"$is_top_level" != xtrue ]; then
Accepting request 295632 from home:michael-chang:sle-12-merge - Merge changes from SLE12 - Do not pass root= when root is on nfs (bnc#894374) * modified grub2-pass-corret-root-for-nfsroot.patch * modified grub2-secureboot-provide-linuxefi-config.patch * modified grub2-secureboot-use-linuxefi-on-uefi.patch - Fix xen pvops kernel not appear on menu (bnc#895286) * modified grub2-fix-menu-in-xen-host-server.patch - Workaround grub2-once (bnc#892358) * added grub2-btrfs-workaround-grub2-once.patch * added grub2-once.service * modified grub2-once - Fix busy-loop and hang while network booting (bnc#870613) * added grub2-netboot-hang.patch - Add warning in grubenv file about editing it directly (bnc#887008) * added grub2-editenv-add-warning-message.patch - Fix broken graphics with efifb on QEMU/KVM and nomodeset (bnc#884558) * added grub2-efi-disable-video-cirrus-and-bochus.patch - Disable video support on Power (bnc#877142) * added grub2-ppc64le-disable-video.patch - Track occupied memory so it can be released on exit (bnc#885026) * added grub2-ppc64le-memory-map.patch - Fix grub.xen config searching path on boot partition (bnc#884828) - Add linux16 and initrd16 to grub.xen (bnc#884830) * added grub2-xen-linux16.patch - VLAN tag support (fate#315753) * added 0001-Add-bootargs-parser-for-open-firmware.patch * added 0002-Add-Virtual-LAN-support.patch - Use chainloader to boot xen.efi under UEFI (bnc#871857) * added grub2-efi-xen-chainload.patch - Use device part of chainloader target, if present (bnc#871857) OBS-URL: https://build.opensuse.org/request/show/295632 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=148
2015-04-13 19:58:16 +02:00
fi
echo "$title_correction_code"
+
+if [ -n "$err_msg" ]; then
+ echo -en "$err_msg" >&2
+fi