Package: grub
Version: 0.97-38
Tags: patch
Severity: normal
The update-grub script currently attempts to determine whether it is running
in a domU or dom0 environment by examining /proc/xen/capabilities. This,
however, has an unfortunate failure mode which my group has run into.
We are using PyGrub, which extracts the kernel and initrd from the guest at
boot time by processing grub's menu.lst. If this VM image is created either
from an HVM environment (by using the Debian installer) or in dom0 (using
something like xen-create-image), update-grub will detect that the
machine is
not currently running in domU, and not add the Xen kernels.
I suggest that an additional option in the menu.lst be added specifying
whether to output a menu.lst appropriate for a domU, a non-virtualized
environment, or the current environment as detected. I have attached my
patch.
--- update-grub.orig 2008-05-04 01:56:25.000000000 -0400
+++ update-grub 2008-05-04 01:56:45.000000000 -0400
@@ -225,6 +225,9 @@
# should grub add "savedefault" to default boot options
savedefault="false"
+# Are we in a Xen domU?
+ indomu="detect"
+
# stores the command line arguments
command_line_arguments=$1
@@ -644,6 +647,8 @@
# Extract the memtest86 value
memtest86=$(GetMenuOpt "memtest86" "$memtest86")
+# Extact the indomu value
+indomu=$(GetMenuOpt "indomu" "$indomu")
# Extract the updatedefaultentry option
updatedefaultentry=$(GetMenuOpt "updatedefaultentry" "$updatedefaultentry")
@@ -740,6 +745,13 @@
echo "# memtest86=$memtest86" >> $buffer
echo >> $buffer
+echo "## How should update-grub deal with Xen kernels?" >> $buffer
+echo "## e.g. indomu=true" >> $buffer
+echo "## indomu=false" >> $buffer
+echo "## indomu=detect" >> $buffer
+echo "# indomu=$indomu" >> $buffer
+echo >> $buffer
+
echo "## should update-grub adjust the value of the default booted system" >>
$buffer
echo "## can be true or false" >> $buffer
echo "# updatedefaultentry=$updatedefaultentry" >> $buffer
@@ -800,9 +812,15 @@
fi
done
-in_domU=
-if [ -e /proc/xen/capabilities ] && ! grep -q "control_d"
/proc/xen/capabilities; then
+if [ "$indomu" == "detect" ]; then
+ in_domU=
+ if [ -e /proc/xen/capabilities ] && ! grep -q "control_d"
/proc/xen/capabilities; then
in_domU=1
+ fi
+else
+ if [ "$indomu" == "true" ]; then
+ in_domU=1
+ fi
fi
sortedKernels=""