Received: from list by lists.gnu.org with archive (Exim 4.71) id 1XUXe8-0000fV-GC for mharc-grub-devel@gnu.org; Thu, 18 Sep 2014 05:05:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUXe0-0000e3-5S for grub-devel@gnu.org; Thu, 18 Sep 2014 05:04:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUXdt-0002bS-5x for grub-devel@gnu.org; Thu, 18 Sep 2014 05:04:52 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:45201) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUXds-0002aM-VN for grub-devel@gnu.org; Thu, 18 Sep 2014 05:04:45 -0400 Received: by mail-wi0-f176.google.com with SMTP id ex7so2670393wid.3 for ; Thu, 18 Sep 2014 02:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=SvbE/zowy91aEExAMrdFzhYAXG0tbFBM1TUk5lh3ewc=; b=G2OmLLTKgRnM5OKgHD1uRG+Yq5uZikMog9pLhLc2b2hJxAe2G07TNPWUN8ApsvKFQW hb5L0haafrXoWlhifX6dvAofTZS6TIsfTR4iIt8gqbsDqg3kS8omWRYE2sDhgIsnxBuB Znas5tuoU8d5CpuexRptA1lKbv5/AkUMA7TSvc3DKe2G2V5u3bIGQT7eyOr8+axCKEC9 wzfp/8se4h57ybF1YMmFCYBiu9uHr/09RMJzNjiv8oR9QsTOAGAr10XlcZbYc0COSzTy B8IPbsaIyVzkLTkO3LDIQwvbgRvxkRAJGvQg5ahIZV3+W89FeivpFlxMY/YUsjkfvFBK K0XA== X-Received: by 10.180.184.20 with SMTP id eq20mr45681780wic.61.1411031078654; Thu, 18 Sep 2014 02:04:38 -0700 (PDT) Received: from localhost.localdomain ([130.57.30.250]) by mx.google.com with ESMTPSA id a5sm4905455wjy.20.2014.09.18.02.04.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 02:04:37 -0700 (PDT) Sender: =?UTF-8?B?5by15paH6I+v?= From: Michael Chang To: grub-devel@gnu.org Subject: [PATCH] fix booting xenlinux kerenl error not on a xen domain Date: Thu, 18 Sep 2014 16:58:36 +0800 Message-Id: <1411030716-31503-1-git-send-email-mchang@suse.com> X-Mailer: git-send-email 1.7.3.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::230 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Sep 2014 09:04:59 -0000 There are two types of xen enabled kernel in linux, one is called xenlinux which is older and can only boot on xen domain but not on any real hardware without xen hypervisor. The other is called pvops which can boot on xen domain as well as real hardware. This patch is to prevent booting xenlinux kernel on real hardware by filtering it out from boot menu. If not the error will show up when attempting to boot it. "Loading Linux xen ..." error: invalid magic number Loading initial ramdisk error: you need to load the kernel first" This patch achieves it by checking the host type, then disable xenlinux kernel from booting on hosts that is not xen pv domU, and meanwhile allow xen pvops kernel to boot. --- util/grub.d/10_linux.in | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index d2e2a8f..b055ccc 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -207,6 +207,30 @@ while [ "x$list" != "x" ] ; do fi done + # check if host is xen pv domU + if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then + 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 + # host is xen HVM guest + xen_pv_domU=false + fi + fi + else + 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 -qx "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 \"` -- 1.7.3.4