* [PATCH] Changes to 10_linux (based on grub2 1.98) to generate boot stanza for Xen hypervisor (fix for bug #30257)
@ 2010-06-26 0:34 Dante Cinco
2010-06-27 14:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 2+ messages in thread
From: Dante Cinco @ 2010-06-26 0:34 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1.1: Type: text/plain, Size: 2089 bytes --]
I have attached a patch that will add the capability in the 10_linux grub2
script to detect and generate boot stanzas in grub.cfg for Xen hypervisors
(if present). It relies on the presence of CONFIG_XEN_DOM0=y to identify
dom0 kernels and pairs them with each version of the hypervisor that is
present. It uses the multiboot command for the Xen hypervisor image and the
module command for the vmlinuz kernel and initrd.img. It also explicitly
sources /etc/default/grub to define a new Xen-only variable called
GRUB_CMDLINE_XEN_DEFAULT. The alternative is to export this in
/usr/sbin/grub-mkconfig like the other GRUB variables. It will also generate
a boot stanza for the dom0 kernel without the hypervisor (in case the
hypervisor is broken).
There is a GNU GRUB bug filed on this which is bug #30257: 10_linux ignores
xen hypervisor entries and dom0 kernels.
Here's an example of an actual Xen boot stanza. The dummy=dummy in the
vmlinuz line is needed due to some bug in GRUB or Xen. Without it, the boot
will hang or stop and hit the initramfs (BusyBox) prompt.
/boot/grub/grub.cfg:
menuentry 'xen-4.0 osa-dom0 , with Linux 2.6.32.15-xen' --class osa-dom0
--class gnu-linux --class gnu --class os {
recordfail
insmod lvm
insmod ext2
set root='(system-dom0_0)'
search --no-floppy --fs-uuid --set cc290394-fa2a-4e13-9024-3bc5a5b9215d
multiboot /boot/xen-4.0.gz com1=115200,8n1 console=com1 dom0_mem=512M
dom0_max_vcpus=1 dom0_vcpus_pin=true iommu=1,passthrough,no-intremap
loglvl=all loglvl_guest=all loglevl=10 debug apic=on
apic_verbosity=verbose extra_guest_irqs=80 acpi=force numa=on
module /boot/vmlinuz-2.6.32.15-xen dummy=dummy
root=/dev/mapper/system-dom0_0 ro quiet earlyprintk=xen loglevel=10 debug
acpi=force console=hvc0,115200n8
module /boot/initrd.img-2.6.32.15-xen
}
/etc/default/grub:
GRUB_CMDLINE_XEN_DEFAULT=" com1=115200,8n1 console=com1 dom0_mem=512M
dom0_max_vcpus=1 dom0_vcpus_pin=true iommu=1,passthrough,no-intremap
loglvl=all loglvl_guest=all loglevl=10 debug apic=on
apic_verbosity=verbose extra_guest_irqs=80 acpi=force numa=on"
- Dante Cinco
[-- Attachment #1.2: Type: text/html, Size: 3039 bytes --]
[-- Attachment #2: 10_linux.patch --]
[-- Type: application/octet-stream, Size: 2785 bytes --]
10_linux grub2 script.
Index: Xen-Ubuntu-10.04/etc/grub.d/10_linux
===================================================================
diff -Naur Ubuntu-10.04/etc/grub.d/10_linux Xen-Ubuntu-10.04/etc/grub.d/10_linux
--- Ubuntu-10.04/etc/grub.d/10_linux 2010-06-24 12:53:56.000000000 -0700
+++ Xen-Ubuntu-10.04/etc/grub.d/10_linux 2010-06-25 15:09:47.000000000 -0700
@@ -66,10 +66,17 @@
version="$2"
recovery="$3"
args="$4"
- if ${recovery} ; then
- title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"
+ xen_path="$6"
+ xen_cmdline="$7"
+ if [ "x$xen_cmdline" != "x" ]; then
+ xen_title=${xen_path%.gz}
+ title="${xen_title#/boot/} $(gettext_quoted "%s, with Linux %s")"
else
- title="$(gettext_quoted "%s, with Linux %s")"
+ if ${recovery} ; then
+ title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"
+ else
+ title="$(gettext_quoted "%s, with Linux %s")"
+ fi
fi
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}"
cat << EOF
@@ -92,9 +99,18 @@
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
EOF
fi
- cat << EOF
+ if [ "x$xen_cmdline" != "x" ]; then
+ module_or_initrd="module"
+ cat << EOF
+ multiboot ${xen_path} ${xen_cmdline}
+ module ${rel_dirname}/${basename} dummy=dummy root=${linux_root_device_thisversion} ro ${args}
+EOF
+ else
+ module_or_initrd="initrd"
+ cat << EOF
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
+ fi
if [ "x$5" != "xquiet" ]; then
cat << EOF
echo '$(gettext_quoted "Loading initial ramdisk ...")'
@@ -102,7 +118,7 @@
fi
if test -n "${initrd}" ; then
cat << EOF
- initrd ${rel_dirname}/${initrd}
+ ${module_or_initrd} ${rel_dirname}/${initrd}
EOF
fi
cat << EOF
@@ -115,6 +131,9 @@
done`
prepare_boot_cache=
+# Need to source this because GRUB_CMDLINE_XEN_DEFAULT is not exported in /usr/sbin/grub-mkconfig
+. /etc/default/grub
+
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
echo "Found linux image: $linux" >&2
@@ -141,6 +160,18 @@
linux_root_device_thisversion=${GRUB_DEVICE}
fi
+ linux_config=${rel_dirname}/config-${version}
+ if grep -q 'CONFIG_XEN_DOM0=y' $linux_config ; then
+ for xen_entry in /boot/xen-*.gz ; do
+ if [ ! -L $xen_entry ]; then
+ echo " dom0 kernel and Xen hypervisor: $xen_entry" >&2
+ linux_entry "${OS}" "${version}" false \
+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
+ quiet "${xen_entry}" "${GRUB_CMDLINE_XEN_DEFAULT}"
+ fi
+ done
+ fi
+
linux_entry "${OS}" "${version}" false \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
quiet
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Changes to 10_linux (based on grub2 1.98) to generate boot stanza for Xen hypervisor (fix for bug #30257)
2010-06-26 0:34 [PATCH] Changes to 10_linux (based on grub2 1.98) to generate boot stanza for Xen hypervisor (fix for bug #30257) Dante Cinco
@ 2010-06-27 14:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-06-27 14:31 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 2692 bytes --]
On 06/26/2010 02:34 AM, Dante Cinco wrote:
>
> I have attached a patch that will add the capability in the 10_linux
> grub2 script to detect and generate boot stanzas in grub.cfg for Xen
> hypervisors (if present). It relies on the presence of
> CONFIG_XEN_DOM0=y to identify dom0 kernels and pairs them with each
> version of the hypervisor that is present. It uses the multiboot
> command for the Xen hypervisor image and the module command for the
> vmlinuz kernel and initrd.img. It also explicitly sources
> /etc/default/grub to define a new Xen-only variable called
> GRUB_CMDLINE_XEN_DEFAULT. The alternative is to export this in
> /usr/sbin/grub-mkconfig like the other GRUB variables. It will also
> generate a boot stanza for the dom0 kernel without the hypervisor (in
> case the hypervisor is broken).
There is a patch on ML already, it has some problems but they are likely
to affect any other approach. I won't even have a look at any
alternative patches unless a good reason for it is given.
>
> There is a GNU GRUB bug filed on this which is bug #30257: 10_linux
> ignores xen hypervisor entries and dom0 kernels.
>
> Here's an example of an actual Xen boot stanza. The dummy=dummy in the
> vmlinuz line is needed due to some bug in GRUB or Xen. Without it, the
> boot will hang or stop and hit the initramfs (BusyBox) prompt.
>
> /boot/grub/grub.cfg:
>
> menuentry 'xen-4.0 osa-dom0 , with Linux 2.6.32.15-xen' --class
> osa-dom0 --class gnu-linux --class gnu --class os {
> recordfail
> insmod lvm
> insmod ext2
> set root='(system-dom0_0)'
> search --no-floppy --fs-uuid --set cc290394-fa2a-4e13-9024-3bc5a5b9215d
> multiboot /boot/xen-4.0.gz com1=115200,8n1 console=com1 dom0_mem=512M
> dom0_max_vcpus=1 dom0_vcpus_pin=true iommu=1,passthrough,no-intremap
> loglvl=all loglvl_guest=all loglevl=10 debug apic=on
> apic_verbosity=verbose extra_guest_irqs=80 acpi=force numa=on
> module /boot/vmlinuz-2.6.32.15-xen dummy=dummy
> root=/dev/mapper/system-dom0_0 ro quiet earlyprintk=xen loglevel=10
> debug acpi=force console=hvc0,115200n8
> module /boot/initrd.img-2.6.32.15-xen
> }
>
> /etc/default/grub:
>
> GRUB_CMDLINE_XEN_DEFAULT=" com1=115200,8n1 console=com1 dom0_mem=512M
> dom0_max_vcpus=1 dom0_vcpus_pin=true iommu=1,passthrough,no-intremap
> loglvl=all loglvl_guest=all loglevl=10 debug apic=on
> apic_verbosity=verbose extra_guest_irqs=80 acpi=force numa=on"
>
> - Dante Cinco
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-27 14:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-26 0:34 [PATCH] Changes to 10_linux (based on grub2 1.98) to generate boot stanza for Xen hypervisor (fix for bug #30257) Dante Cinco
2010-06-27 14:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.