package grub-pc
tag 505517 patch upstream
thanks

Le jeudi 13 novembre 2008 09:36:03, vous avez écrit :
> Hi,
>
> Willing to try Xen, I installed "xen-linux-system-2.6.26-1-xen-amd64",
> which came with a bunch of packages…
>
> When I tried to boot the corresponding image, I got an error in Grub.
>
> AFAIK and from what I gathered on the web, the entry "should be":
>
>       multiboot /xen-3.2-1-amd64.gz dom0_mem=1024M
>       module  /vmlinuz-2.6.26-1-xen-amd64 root=/dev/mapper/Tamino-Root ro 
> quiet
> vga=792
>       module  /initrd.img-2.6.26-1-xen-amd64
>
> instead of what is shown below. And in fact, it works.
>
> I think that booting the Xen hypervisor should be more straightaway than
> now (I had to modify the grub-pc configuration).
>
> Regards,
>
> Didier

Hi, 

Here is a patch that solves bug #505517 in two steps :

* grub-pc_00_add_xen_support.patch
        Removes the xen kernels from 10_linux's listing
        (simply blacklisting *-xen-* kernels and initrds)

* grub-pc_01_add_xen_support.patch
* grub-pc_02_add_xen_support.patch
* grub-pc_03_add_xen_support.patch
        Add a 10_xen in /etc/grub.d/ for support of the Xen hypervisors
        Lists all the *-xen-* kernels for each hypervisor version

Maybe 00 should land in grub-pc and 01-03 in some other xen-unique package 
(e.g. 
the hypervisor itself). Thus cc-ing Debian Xen Team.

I hope that a patch inspired by these could allow a Lenny release 
with "compatible" Xen and grub-pc.

Best regards, 

OdyX

-- 
Didier Raboud, proud Debian user.
CH-1802 Corseaux
[EMAIL PROTECTED]
--- etc/grub.d/10_linux	2008-11-10 16:27:12.000000000 +0100
+++ /etc/grub.d/10_linux	2008-11-13 18:22:20.000000000 +0100
@@ -89,7 +89,13 @@
 }
 
 list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
-        if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
+        if grub_file_is_not_garbage "$i" ; then
+		# Avoid listing the Xen images which have to be booted through the hypervisor
+		case $i in
+			*-xen-*);;
+			*) echo -n "$i " ;;
+		esac
+	fi
       done`
 
 if [ "x$list" != "x" ] ; then
--- etc/grub.d/10_xen	1970-01-01 01:00:00.000000000 +0100
+++ /etc/grub.d/10_xen	2008-11-17 15:36:39.000000000 +0100
@@ -0,0 +1,174 @@
+#! /bin/sh -e
+
+# update-grub helper script.
+# Copyright (C) 2006,2007,2008  Free Software Foundation, Inc.
+#
+# GRUB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+. ${libdir}/grub/update-grub_lib
+
+if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
+  OS=Xen
+else
+  OS="${GRUB_DISTRIBUTOR} Xen"
+fi
+
+# loop-AES arranges things so that /dev/loop/X can be our root device, but
+# the initrds that Linux uses don't like that.
+case ${GRUB_DEVICE} in
+  /dev/loop/*|/dev/loop[0-9])
+    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
+  ;;
+esac
+
+if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_XEN_UUID}" = "xtrue" ] \
+    || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
+    || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE}`" != "" ] ; then
+  XEN_ROOT_DEVICE=${GRUB_DEVICE}
+else
+  XEN_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
+fi
+
+test_numeric ()
+{
+  local a=$1
+  local cmp=$2
+  local b=$3
+  if [ "$a" = "$b" ] ; then
+    case $cmp in
+      ge|eq|le) return 0 ;;
+      gt|lt) return 1 ;;
+    esac
+  fi
+  if [ "$cmp" = "lt" ] ; then
+    c=$a
+    a=$b
+    b=$c
+  fi
+  if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+test_gt ()
+{
+  local a=`echo $1 | sed -e "s,.*/vmlinu[zx]-,,g;s/[._-]\(pre\|rc\|test\|git\|old\)/~\1/g"`
+  local b=`echo $2 | sed -e "s,.*/vmlinu[zx]-,,g;s/[._-]\(pre\|rc\|test\|git\|old\)/~\1/g"`
+  if [ "x$b" = "x" ] ; then
+    return 0
+  fi
+  dpkg --compare-versions "$a" gt "$b"
+  return $?
+}
+
+find_latest ()
+{
+  local a=""
+  for i in $@ ; do
+    if test_gt "$i" "$a" ; then
+      a="$i"
+    fi
+  done
+  echo "$a"
+}
+
+xen_list=`for i in /boot/xen-*.gz /xen-*.gz ; do
+		if grub_file_is_not_garbage "$i" ; then
+			echo -n "$i ";
+		fi
+	done`
+
+if [ "x$xen_list" != "x" ] ; then
+  prepare_grub_to_access_device ${GRUB_DEVICE_BOOT}
+fi
+
+while [ "x$xen_list" != "x" ] ; do
+  xen=`find_latest $xen_list`
+  echo "Found Xen hypervisor image: $xen" >&2
+  basename_x=`basename $xen`
+  dirname_x=`dirname $xen`
+  rel_dirname_x=`make_system_path_relative_to_its_root $dirname_x`
+  version_x=`echo $basename_x | sed -e "s,^[^0-9]*-,,g" | sed -e "s,.gz,,g"`
+  alt_version_x=`echo $version_x | sed -e "s,\.old$,,g"`
+
+  list=`for i in /boot/vmlinu[xz]-*-xen-* /vmlinu[xz]-*-xen-* ; do
+        if grub_file_is_not_garbage "$i" ; then
+		echo -n "$i " ;
+	fi
+      done`
+
+  while [ "x$list" != "x" ] ; do
+    linux=`find_latest $list`
+    echo "  Found linux image: $linux" >&2
+    basename=`basename $linux`
+    dirname=`dirname $linux`
+    rel_dirname=`make_system_path_relative_to_its_root $dirname`
+    version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
+    alt_version=`echo $version | sed -e "s,\.old$,,g"`
+    linux_root_device_thisversion="${XEN_ROOT_DEVICE}"
+
+    initrd=
+    for i in "initrd.img-${version}" "initrd-${version}.img" \
+  	   "initrd.img-${alt_version}" "initrd-${alt_version}.img"; do
+      if test -e "${dirname}/${i}" ; then
+        initrd="$i"
+        break
+      fi
+    done
+    if test -n "${initrd}" ; then
+      echo "  Found initrd image: ${dirname}/${initrd}" >&2
+    else
+      # "UUID=" magic is parsed by initrds.  Since there's no initrd, it can't work here.
+      linux_root_device_thisversion=${GRUB_DEVICE}
+    fi
+
+    cat << EOF
+menuentry "${OS} hypervisor ${version_x}, linux ${version}" {
+	multiboot	${rel_dirname_x}/${basename_x} ${GRUB_CMDLINE_XEN}
+	module		${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}
+EOF
+  if test -n "${initrd}" ; then
+    cat << EOF
+	module		${rel_dirname}/${initrd}
+EOF
+  fi
+  cat << EOF
+}
+EOF
+
+  cat << EOF
+menuentry "${OS} hypervisor ${version_x}, linux ${version} (single-user mode)" {
+	multiboot       ${rel_dirname_x}/${basename_x} ${GRUB_CMDLINE_XEN}
+	module		${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro single ${GRUB_CMDLINE_LINUX}
+EOF
+  if test -n "${initrd}" ; then
+    cat << EOF
+	module		${rel_dirname}/${initrd}
+EOF
+  fi
+  cat << EOF
+}
+EOF
+
+  list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+done
+
+  xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $xen | tr '\n' ' '`
+done
+
--- usr/sbin/update-grub	2008-11-10 16:27:12.000000000 +0100
+++ /usr/sbin/update-grub	2008-11-17 15:36:07.000000000 +0100
@@ -152,7 +152,7 @@
 export GRUB_DEVICE GRUB_DEVICE_UUID GRUB_DEVICE_BOOT GRUB_DEVICE_BOOT_UUID GRUB_FS GRUB_FONT_PATH GRUB_PRELOAD_MODULES
 
 # These are optional, user-defined variables.
-export GRUB_DEFAULT GRUB_TIMEOUT GRUB_DISTRIBUTOR GRUB_CMDLINE_LINUX GRUB_CMDLINE_LINUX_DEFAULT GRUB_TERMINAL GRUB_SERIAL_COMMAND GRUB_DISABLE_LINUX_UUID
+export GRUB_DEFAULT GRUB_TIMEOUT GRUB_DISTRIBUTOR GRUB_CMDLINE_LINUX GRUB_CMDLINE_LINUX_DEFAULT GRUB_CMDLINE_XEN GRUB_TERMINAL GRUB_SERIAL_COMMAND GRUB_DISABLE_LINUX_UUID GRUB_DISABLE_XEN_UUID
 
 exec > ${grub_cfg}.new
 
--- etc/default/grub	2008-06-29 19:08:18.000000000 +0200
+++ /etc/default/grub	2008-11-17 17:48:40.000000000 +0100
@@ -10,3 +10,10 @@
 
 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
 #GRUB_DISABLE_LINUX_UUID=true
+
+# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Xen
+#GRUB_DISABLE_XEN_UUID=true
+
+# Alter your Xen options (if existant)
+GRUB_CMDLINE_XEN='dom0_mem=1024M vga=ask'
+

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to