Bug#343076: [Pkg-xen-devel] xen linux-image packages; initrd.img

Thomas Schwinge tschwinge at gnu.org
Tue Jul 18 17:15:08 UTC 2006


Hello!

On Thu, Jul 06, 2006 at 04:34:02PM +0100, Alastair McKinstry wrote:
> Have a look at bug report http://bugs.debian.org/343076 ; I've
> a patch  to update-grub to add Xen clauses to menu.lst.

Thanks, that's what I use now.


On Tue, Jul 18, 2006 at 09:53:36AM -0300, Otavio Salvador wrote:
> Thomas Schwinge <tschwinge at gnu.org> writes:
> > Which version of the Debian grub package is this patch supposed to apply
> > cleanly to?
> 
> Unstable one or svn snapshot from HEAD

It doesn't apply cleanly to unstable (that's what I had tried) and svn in
the meantime already contains the patch.

I fixed some bugs and did some further improvements; please consider the
attached patch.  There would be -- at least in my opinion -- a lot more
to refactor in update-grub, but I stopped at this point.


Remaining question:

* Is it wise to have the Xen entries _after_ the non-Xen entries in
GRUB's menu.lst?  (Think w.r.t. booting without a connected terminal, but
still having a non-Xen kernel installed for whatever reasons.)

* Is it wise to not have update-grub create a ``single-user mode'' /
``recovery mode'' entry for Xen kernels?

Shall I send in patches to change those two the way I indicated?


Regards,
 Thomas
-------------- next part --------------
Index: update-grub
===================================================================
--- update-grub	(Revision 262)
+++ update-grub	(Arbeitskopie)
@@ -326,7 +326,7 @@
 	lockold="false"
 
 # Xen kernel options to use with the default xen boot options
-xenoptions="console=tty0 quiet"
+xenoptions="console=tty0"
 
 # options to use with the alternative boot options
 	altoptions="(single-user mode) single"
@@ -594,8 +594,22 @@
 	local initrd; initrd=$1; shift
 	local savedefault; savedefault=$1; shift
 	local lockold; lockold=$1; shift
+	local hypervisor
+	if [ -n "$1" ]; then
+		# Hypervisor.
+		hypervisor=$1; shift
+		local hypervisor_image; hypervisor_image=$1; shift
+		local hypervisor_version; hypervisor_version=$1; shift
+		local hypervisor_options; hypervisor_options=$1; shift
+	fi
 
-	echo -n "title		$title" >> $buffer
+	echo -n "title		" >> $buffer
+
+	if [ -n "$hypervisor" ]; then
+		echo -n "$hypervisor $hypervisor_version / " >> $buffer
+	fi
+
+	echo -n "$title" >> $buffer
 	if [ -n "$kernel_version" ]; then
 		echo -n ", kernel $kernel_version" >> $buffer
 	fi
@@ -614,7 +628,17 @@
 	fi
 
 	echo "root		$grub_root_device" >> $buffer
-	echo -n "kernel		$kernel"  >> $buffer
+
+	echo -n "kernel		"  >> $buffer
+	if [ -n "$hypervisor" ]; then
+		echo -n "$hypervisor_image" >> $buffer
+		if [ -n "$hypervisor_options" ]; then
+			echo -n " $hypervisor_options"  >> $buffer
+		fi
+		echo >> $buffer
+		echo -n "module		"  >> $buffer
+	fi
+	echo -n "$kernel"  >> $buffer
 	if [ -n "$kernel_options" ]; then
 		echo -n " $kernel_options"  >> $buffer
 	fi
@@ -624,7 +648,12 @@
 	echo >> $buffer
 
 	if [ -n "$initrd" ]; then
-		echo "initrd		$initrd" >> $buffer
+		if [ -n "$hypervisor" ]; then
+			echo -n "module		" >> $buffer
+		else
+			echo -n "initrd		" >> $buffer
+		fi
+		echo "$initrd" >> $buffer
 	fi
 
 	if test x"$savedefault" = x"true" ; then
@@ -635,42 +664,6 @@
 }
 
 
-write_xen_kernel_entry()
-{
-	hypervisor_version=$1
-	hypervisor=$2
-	kernel_version=$3
-	grub_root_device=$4
-	kernel=$5
-	kernel_options=$6
-	recovery_suffix=$7
-	initrd=$8
-	savedefault=$9
-
-	echo -n "title		Xen $hypervisor_version / XenLinux $kernel_version " >> $buffer
-	echo >> $buffer
-
-	echo "root		$grub_root_device" >> $buffer
-	echo "kernel		$hypervisor" >> $buffer
-
-	echo -n "module		$kernel $kernel_options"  >> $buffer
-	if [ -n "$recovery_desc" ]; then
-		echo -n " $recovery_suffix"	 >> $buffer
-	fi
-	echo >> $buffer
-
-
-	if [ -n "$initrd" ]; then
-		echo "module		$initrd" >> $buffer
-	fi
-
-	if test x"$savedefault" = x"true" ; then
-		echo "savedefault" >> $buffer
-	fi
-	echo "boot" >> $buffer
-	echo >> $buffer
-}
-
 echo -n "Testing for an existing GRUB menu.list file ... " >&2
 
 # Test if our menu file exists
@@ -870,7 +863,7 @@
 
 
 xenKernels=""
-for ver in $(grep CONFIG_XEN_PRIVILEGED_GUEST=y /boot/config* | sed -e 's/\/boot\/config-\([^:]*\):[^:]*/\1/' ) ; do
+for ver in `grep -l CONFIG_XEN_PRIVILEGED_GUEST=y /boot/config* | sed -e s%/boot/config-%%`; do
   # ver is a kernel version
   kern="/boot/vmlinuz-$ver"
   if [ -r $kern ] ; then
@@ -923,12 +916,11 @@
 fi
 
 hypervisors=""
-for hyp in $(ls /boot | egrep "xen-.*.gz" ) ; do
-   if [ ! -h /boot/$hyp ] ; then
-        hypervisors="$hypervisors $hyp"
-   fi
+for hyp in /boot/xen-*.gz; do
+    if [ ! -h "$hyp" ] && [ -f "$hyp" ]; then
+	hypervisors="$hypervisors `basename "$hyp"`"
+    fi
 done
-echo "hypervisors $hypervisors"
 
 # figure out where grub looks for the kernels at boot time
 kernel_dir=/boot
@@ -1035,12 +1027,9 @@
 done
 
 # Now the Xen entries
-for hyp in $hypervisors ; do
+for hypervisor in $hypervisors; do
+    hypVersion=`basename "$hypervisor" .gz | sed s%xen-%%`
 
-    hypName=$(basename $hyp)
-    hypVersion=$(echo $hypName | sed -e 's/xen-//' | sed -e 's/.gz//')
-    hypervisor=/boot/$hyp
-   
     for kern in $xenKernels ; do
                 if test ! x"$howmany" = x"all" ; then
         	        if [ $counter -gt $howmany ] ; then
@@ -1062,8 +1051,9 @@
 
         	kernelVersion=$(echo $kernelVersion | sed -e 's/^-//')
 
-		write_xen_kernel_entry "$hypVersion" "$hypervisor" "$kernelVersion" \
-		  "$grub_root_device" "$kernel" "$currentOpt $xenoptions" "" "$initrd" "false"
+		write_kernel_entry "$kernelVersion" '' '' "$grub_root_device" \
+		  "$kernel" "$currentOpt $xenoptions" '' "$initrd" true '' \
+		  Xen "$kernel_dir/$hypervisor" "$hypVersion" ''
 	done
 done
 


More information about the Pkg-grub-devel mailing list