Package: grub
Version: 0.97-20
Severity: normal
Tags: patch

xen's pygrub allows booting a xen domU using a kernel loaded from inside
that domU's disk. It looks at the domU's /boot/grub/menu.lst file, and
displays a grub-like list of kernels. For this to work though, the
menu.lst should include xen kernels, and exclude non-xen kernels, which
is the opposite of what update-grub puts in there now.

I've attached a patch that makes update-grub smart about this. If the
system is a dom0, or not a xen system, it behaves as before, excluding
the xen kernels from menu.lst. If the system is a domU, it includes only
xen kernels.

I've tested this patch on all three system types, and several kernel
versions, and it seems to work well.

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-3-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages grub depends on:
ii  libc6                        2.3.6.ds1-9 GNU C Library: Shared libraries
ii  libncurses5                  5.5-5       Shared libraries for terminal hand

grub recommends no packages.

-- no debconf information

-- 
see shy jo
--- /usr/sbin/update-grub	2006-11-09 07:39:33.000000000 -0500
+++ ./update-grub	2006-12-25 20:55:24.000000000 -0500
@@ -887,13 +887,26 @@
     fi
 done
 
+in_domU=
+if [ -e /proc/xen/capabilities ] && ! grep -q "control_d" /proc/xen/capabilities; then
+	in_domU=1
+fi
+
 sortedKernels=""
-for kern in $(/bin/ls -1vr /boot | grep -v "dpkg-*" | grep -v "xen" | grep "^vmlinuz-") ; do
-	# found a kernel
-        if `echo "$xenKernels" | grep -q "$kern "` ; then
+for kern in $(/bin/ls -1vr /boot | grep -v "dpkg-*" | grep "^vmlinuz-") ; do
+	if `echo "$xenKernels" | grep -q "$kern "` || `echo "$kern" | grep -q "xen"`; then
+		is_xen=1
+	else
+		is_xen=
+	fi
+
+	if [ ! "$in_domU" ] && [ "$is_xen" ]; then
+	  # skip xen kernels
           continue
+        elif [ "$in_domU" ] && ! [ "$is_xen" ]; then
+	  # skip non-xen kernels
+	  continue
         fi
-        # not a Xen kernel
         kern="/boot/$kern"
 	newerKernels=""
 	for i in $sortedKernels ; do

Attachment: signature.asc
Description: Digital signature

Reply via email to