Bug#343076: [Pkg-xen-devel] xen linux-image packages; initrd.img
Thomas Schwinge
tschwinge at gnu.org
Sun Jul 23 10:08:37 UTC 2006
Hello again!
On Sun, Jul 23, 2006 at 12:05:23PM +0200, I wrote:
> On Wed, Jul 19, 2006 at 09:10:19AM +0100, Alastair McKinstry wrote:
> > Thomas Schwinge wrote:
> > > 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.
>
> Attached is an updated patch against the Debian grub svn repository.
Blah, it helps to actually attach the patch...
Regards,
Thomas
-------------- next part --------------
Index: update-grub
===================================================================
--- update-grub (Revision 262)
+++ update-grub (Arbeitskopie)
@@ -325,9 +325,12 @@
# should grub lock the old kernels
lockold="false"
-# Xen kernel options to use with the default xen boot options
-xenoptions="console=tty0 quiet"
+# Xen hypervisor options to use with the default Xen boot option
+ xenhopt=""
+# Xen Linux kernel options to use with the default Xen boot option
+ xenkopt="console=tty0"
+
# options to use with the alternative boot options
altoptions="(single-user mode) single"
@@ -594,8 +597,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 +631,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 +651,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 +667,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
@@ -737,9 +733,12 @@
# Extract the lockold value
lockold=$(GetMenuOpt "lockold" "$lockold")
-# Extract Xen kernel options
-xenoptions=$(GetMenuOpt "xenoptions" "$xenoptions")
+# Extract Xen hypervisor options
+xenhopt=$(GetMenuOpt "xenhopt" "$xenhopt")
+# Extract Xen Linux kernel options
+xenkopt=$(GetMenuOpt "xenkopt" "$xenkopt")
+
# Extract the howmany value
howmany=$(GetMenuOpt "howmany" "$howmany")
@@ -805,10 +804,14 @@
echo "# lockold=$lockold" >> $buffer
echo >> $buffer
-echo "## Xen options top use with the default Xen boot kernel option " >> $buffer
-echo "# xenoptions=$xenoptions" >> $buffer
+echo "## Xen hypervisor options to use with the default Xen boot option" >> $buffer
+echo "# xenhopt=$xenhopt" >> $buffer
echo >> $buffer
+echo "## Xen Linux kernel options to use with the default Xen boot option" >> $buffer
+echo "# xenkopt=$xenkopt" >> $buffer
+echo >> $buffer
+
echo "## altoption boot targets option" >> $buffer
echo "## multiple altoptions lines are allowed" >> $buffer
echo "## e.g. altoptions=(extra menu suffix) extra boot options" >> $buffer
@@ -870,7 +873,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 +926,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
@@ -970,6 +972,39 @@
## heres where we start writing out the kernel entries
counter=0
+
+# Xen entries first.
+for hypervisor in $hypervisors; do
+ hypVersion=`basename "$hypervisor" .gz | sed s%xen-%%`
+
+ for kern in $xenKernels ; do
+ if test ! x"$howmany" = x"all" ; then
+ if [ $counter -gt $howmany ] ; then
+ break
+ fi
+ fi
+ kernelName=$(basename $kern)
+
+ kernelVersion=$(echo $kernelName | sed -e 's/vmlinuz//')
+ initrdName=$(FindInitrdName "/boot" "$kernelVersion")
+ initrd=""
+
+ kernel=$kernel_dir/$kernelName
+ if [ -n "$initrdName" ] ; then
+ initrd=$kernel_dir/$initrdName
+ fi
+
+ echo "Found Xen hypervisor $hypVersion, kernel: $kernel"
+
+ kernelVersion=$(echo $kernelVersion | sed -e 's/^-//')
+ currentOpt=$(get_kernel_opt $kernelVersion)
+
+ write_kernel_entry "$kernelVersion" '' '' "$grub_root_device" \
+ "$kernel" "$currentOpt $xenkopt" '' "$initrd" true '' \
+ Xen "$kernel_dir/$hypervisor" "$hypVersion" "$xenhopt"
+ done
+done
+
for kern in $sortedKernels ; do
counter=$(($counter + 1))
if test ! x"$howmany" = x"all" ; then
@@ -1034,39 +1069,6 @@
fi
done
-# Now the Xen entries
-for hyp in $hypervisors ; do
-
- 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
- break
- fi
- fi
- kernelName=$(basename $kern)
-
- kernelVersion=$(echo $kernelName | sed -e 's/vmlinuz//')
- initrdName=$(FindInitrdName "/boot" "$kernelVersion")
- initrd=""
-
- kernel=$kernel_dir/$kernelName
- if [ -n "$initrdName" ] ; then
- initrd=$kernel_dir/$initrdName
- fi
-
- echo "Found Xen hypervisor $hypVersion, kernel: $kernel"
-
- kernelVersion=$(echo $kernelVersion | sed -e 's/^-//')
-
- write_xen_kernel_entry "$hypVersion" "$hypervisor" "$kernelVersion" \
- "$grub_root_device" "$kernel" "$currentOpt $xenoptions" "" "$initrd" "false"
- done
-done
-
memtest86names="memtest86 memtest86+"
More information about the Pkg-grub-devel
mailing list