2012-07-23 10:00:52 +02:00
|
|
|
From b411dc88b46890400a2e1ba0aa8650e00f738c23 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Michael Chang <mchang@suse.com>
|
|
|
|
Date: Thu, 19 Jul 2012 18:43:55 +0800
|
|
|
|
Subject: [PATCH] fix menu in xen host server
|
|
|
|
|
|
|
|
References: bnc#771689, bnc#757895
|
|
|
|
Patch-Mainline: no
|
|
|
|
|
|
|
|
When system is configred as "Xen Virtual Machines Host Server", the
|
|
|
|
grub2 menu is not well organized. We could see some issues on it.
|
|
|
|
|
|
|
|
- Many duplicated xen entries generated by links to xen hypervisor
|
|
|
|
- Non bootable kernel entries trying to boot xen kernel natively
|
|
|
|
- The -dbg xen hypervisor takes precedence over release version
|
|
|
|
|
|
|
|
This patch fixes above three issues.
|
|
|
|
---
|
|
|
|
util/grub-mkconfig_lib.in | 5 +++++
|
|
|
|
util/grub.d/10_linux.in | 12 ++++++++++--
|
|
|
|
util/grub.d/20_linux_xen.in | 6 ++++--
|
|
|
|
3 files changed, 19 insertions(+), 4 deletions(-)
|
|
|
|
|
2014-01-10 21:19:21 +01:00
|
|
|
Index: grub-2.02~beta2/util/grub-mkconfig_lib.in
|
2013-07-11 13:28:40 +02:00
|
|
|
===================================================================
|
2014-01-10 21:19:21 +01:00
|
|
|
--- grub-2.02~beta2.orig/util/grub-mkconfig_lib.in
|
|
|
|
+++ grub-2.02~beta2/util/grub-mkconfig_lib.in
|
|
|
|
@@ -248,6 +248,11 @@ version_test_gt ()
|
2012-07-23 10:00:52 +02:00
|
|
|
*.old:*.old) ;;
|
|
|
|
*.old:*) version_test_gt_a="`echo -n "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;;
|
|
|
|
*:*.old) version_test_gt_b="`echo -n "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;;
|
|
|
|
+# bnc#757895 - Grub2 menu items incorrect when "Xen Virtual Machines Host Server" selected
|
|
|
|
+# The dbg version should be placed after release version
|
|
|
|
+ dbg-*:dbg-*) ;;
|
|
|
|
+ dbg-*:*) version_test_gt_a="" ;;
|
|
|
|
+ *:dbg-*) version_test_gt_b="" ;;
|
|
|
|
esac
|
|
|
|
version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b"
|
|
|
|
return "$?"
|
2014-01-10 21:19:21 +01:00
|
|
|
Index: grub-2.02~beta2/util/grub.d/20_linux_xen.in
|
2013-07-11 13:28:40 +02:00
|
|
|
===================================================================
|
2014-01-10 21:19:21 +01:00
|
|
|
--- grub-2.02~beta2.orig/util/grub.d/20_linux_xen.in
|
|
|
|
+++ grub-2.02~beta2/util/grub.d/20_linux_xen.in
|
2014-03-04 13:14:10 +01:00
|
|
|
@@ -26,6 +26,12 @@ datarootdir="@datarootdir@"
|
|
|
|
export TEXTDOMAIN=@PACKAGE@
|
|
|
|
export TEXTDOMAINDIR="@localedir@"
|
|
|
|
|
|
|
|
+if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then
|
|
|
|
+# we're running on xen domU guest
|
|
|
|
+# prevent setting up nested virt on HVM or PV domU guest
|
|
|
|
+ exit 0
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
CLASS="--class gnu-linux --class gnu --class os --class xen"
|
|
|
|
|
|
|
|
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
|
|
|
@@ -165,7 +171,9 @@ file_is_not_sym () {
|
2012-07-23 10:00:52 +02:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
-xen_list=`for i in /boot/xen*; do
|
|
|
|
+# bnc#757895 - Grub2 menu items incorrect when "Xen Virtual Machines Host Server" selected
|
2014-03-04 13:14:10 +01:00
|
|
|
+# wildcard expasion with correct suffix (.gz) for not generating many duplicated menu entries
|
2012-07-23 10:00:52 +02:00
|
|
|
+xen_list=`for i in /boot/xen*.gz; do
|
2014-03-04 13:14:10 +01:00
|
|
|
if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi
|
2012-07-23 10:00:52 +02:00
|
|
|
done`
|
|
|
|
prepare_boot_cache=
|
2014-03-04 13:14:10 +01:00
|
|
|
Index: grub-2.02~beta2/util/grub.d/10_linux.in
|
|
|
|
===================================================================
|
|
|
|
--- grub-2.02~beta2.orig/util/grub.d/10_linux.in
|
|
|
|
+++ grub-2.02~beta2/util/grub.d/10_linux.in
|
|
|
|
@@ -207,6 +207,40 @@ while [ "x$list" != "x" ] ; do
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
+ # try to get the kernel config if $linux is a symlink
|
|
|
|
+ if test -z "${config}" ; then
|
|
|
|
+ lnk_version=`basename \`readlink -f $linux\` | sed -e "s,^[^0-9]*-,,g"`
|
|
|
|
+ if (test -n ${lnk_version} && test -e "${dirname}/config-${lnk_version}") ; then
|
|
|
|
+ config="${dirname}/config-${lnk_version}"
|
|
|
|
+ fi
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ # check if we are in xen domU
|
|
|
|
+ if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then
|
|
|
|
+ # we're running on xen domU guest
|
|
|
|
+ dmi=/sys/class/dmi/id
|
|
|
|
+ if [ -r "${dmi}/product_name" -a -r "${dmi}/sys_vendor" ]; then
|
|
|
|
+ product_name=`cat ${dmi}/product_name`
|
|
|
|
+ sys_vendor=`cat ${dmi}/sys_vendor`
|
|
|
|
+ if test "${sys_vendor}" = "Xen" -a "${product_name}" = "HVM domU"; then
|
|
|
|
+ # xen HVM guest
|
|
|
|
+ xen_pv_domU=false
|
|
|
|
+ fi
|
|
|
|
+ fi
|
|
|
|
+ else
|
|
|
|
+ # we're running on baremetal or xen dom0
|
|
|
|
+ xen_pv_domU=false
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ if test "$xen_pv_domU" = "false" ; then
|
|
|
|
+ # prevent xen kernel without pv_opt support from booting
|
|
|
|
+ if (grep -qx "CONFIG_XEN=y" "${config}" 2> /dev/null && grep -qvx "CONFIG_PARAVIRT=y" "${config}" 2> /dev/null); then
|
|
|
|
+ echo "Skip xenlinux kernel $linux" >&2
|
|
|
|
+ list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
|
|
|
|
+ continue
|
|
|
|
+ fi
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
initramfs=
|
|
|
|
if test -n "${config}" ; then
|
|
|
|
initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
|