* [PATCH] fix booting xenlinux kerenl error not on a xen domain
@ 2014-09-18 8:58 Michael Chang
2014-09-21 15:27 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 3+ messages in thread
From: Michael Chang @ 2014-09-18 8:58 UTC (permalink / raw)
To: grub-devel
There are two types of xen enabled kernel in linux, one is called
xenlinux which is older and can only boot on xen domain but not on any
real hardware without xen hypervisor. The other is called pvops which
can boot on xen domain as well as real hardware.
This patch is to prevent booting xenlinux kernel on real hardware by
filtering it out from boot menu. If not the error will show up when
attempting to boot it.
"Loading Linux xen ..."
error: invalid magic number
Loading initial ramdisk
error: you need to load the kernel first"
This patch achieves it by checking the host type, then disable xenlinux
kernel from booting on hosts that is not xen pv domU, and meanwhile
allow xen pvops kernel to boot.
---
util/grub.d/10_linux.in | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index d2e2a8f..b055ccc 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -207,6 +207,30 @@ while [ "x$list" != "x" ] ; do
fi
done
+ # check if host is xen pv domU
+ if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then
+ dmi=/sys/class/dmi/id
+ if [ -r "${dmi}/product_name" -a -r "${dmi}/sys_vendor" ]; then
+ product_name=`cat ${dmi}/product_name`
+ sys_vendor=`cat ${dmi}/sys_vendor`
+ if test "${sys_vendor}" = "Xen" -a "${product_name}" = "HVM domU"; then
+ # host is xen HVM guest
+ xen_pv_domU=false
+ fi
+ fi
+ else
+ xen_pv_domU=false
+ fi
+
+ if test "$xen_pv_domU" = "false" ; then
+ # prevent xen kernel without pv_opt support from booting
+ if (grep -qx "CONFIG_XEN=y" "${config}" 2> /dev/null && ! grep -qx "CONFIG_PARAVIRT=y" "${config}" 2> /dev/null); then
+ echo "Skip xenlinux kernel $linux" >&2
+ list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+ continue
+ fi
+ fi
+
initramfs=
if test -n "${config}" ; then
initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fix booting xenlinux kerenl error not on a xen domain
2014-09-18 8:58 [PATCH] fix booting xenlinux kerenl error not on a xen domain Michael Chang
@ 2014-09-21 15:27 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-09-23 6:52 ` Michael Chang
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-09-21 15:27 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 2675 bytes --]
On 18.09.2014 10:58, Michael Chang wrote:
> There are two types of xen enabled kernel in linux, one is called
> xenlinux which is older and can only boot on xen domain but not on any
> real hardware without xen hypervisor. The other is called pvops which
> can boot on xen domain as well as real hardware.
>
> This patch is to prevent booting xenlinux kernel on real hardware by
> filtering it out from boot menu. If not the error will show up when
> attempting to boot it.
>
> "Loading Linux xen ..."
> error: invalid magic number
> Loading initial ramdisk
> error: you need to load the kernel first"
>
> This patch achieves it by checking the host type, then disable xenlinux
> kernel from booting on hosts that is not xen pv domU, and meanwhile
> allow xen pvops kernel to boot.
> ---
> util/grub.d/10_linux.in | 24 ++++++++++++++++++++++++
> 1 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
> index d2e2a8f..b055ccc 100644
> --- a/util/grub.d/10_linux.in
> +++ b/util/grub.d/10_linux.in
> @@ -207,6 +207,30 @@ while [ "x$list" != "x" ] ; do
> fi
> done
>
> + # check if host is xen pv domU
> + if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then
> + dmi=/sys/class/dmi/id
> + if [ -r "${dmi}/product_name" -a -r "${dmi}/sys_vendor" ]; then
> + product_name=`cat ${dmi}/product_name`
> + sys_vendor=`cat ${dmi}/sys_vendor`
> + if test "${sys_vendor}" = "Xen" -a "${product_name}" = "HVM domU"; then
> + # host is xen HVM guest
> + xen_pv_domU=false
> + fi
> + fi
> + else
> + xen_pv_domU=false
> + fi
> +
Please don't determine system type at config file generation. Think of
e.g. systems that can be bootable in either configuration. Use $grub_cpu
and $grub_platofem runtime variables.
> + if test "$xen_pv_domU" = "false" ; then
> + # prevent xen kernel without pv_opt support from booting
> + if (grep -qx "CONFIG_XEN=y" "${config}" 2> /dev/null && ! grep -qx "CONFIG_PARAVIRT=y" "${config}" 2> /dev/null); then
We're moving away from grepping in $config. Can you see if it can be
integrated with grub_file?
> + echo "Skip xenlinux kernel $linux" >&2
> + list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
> + continue
> + fi
> + fi
> +
> initramfs=
> if test -n "${config}" ; then
> initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
> -- 1.7.3.4 _______________________________________________ Grub-devel
> mailing list Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix booting xenlinux kerenl error not on a xen domain
2014-09-21 15:27 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-09-23 6:52 ` Michael Chang
0 siblings, 0 replies; 3+ messages in thread
From: Michael Chang @ 2014-09-23 6:52 UTC (permalink / raw)
To: The development of GNU GRUB
On Sun, Sep 21, 2014 at 05:27:02PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> On 18.09.2014 10:58, Michael Chang wrote:
> > There are two types of xen enabled kernel in linux, one is called
> > xenlinux which is older and can only boot on xen domain but not on any
> > real hardware without xen hypervisor. The other is called pvops which
> > can boot on xen domain as well as real hardware.
> >
> > This patch is to prevent booting xenlinux kernel on real hardware by
> > filtering it out from boot menu. If not the error will show up when
> > attempting to boot it.
> >
> > "Loading Linux xen ..."
> > error: invalid magic number
> > Loading initial ramdisk
> > error: you need to load the kernel first"
> >
> > This patch achieves it by checking the host type, then disable xenlinux
> > kernel from booting on hosts that is not xen pv domU, and meanwhile
> > allow xen pvops kernel to boot.
> > ---
> > util/grub.d/10_linux.in | 24 ++++++++++++++++++++++++
> > 1 files changed, 24 insertions(+), 0 deletions(-)
> >
> > diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
> > index d2e2a8f..b055ccc 100644
> > --- a/util/grub.d/10_linux.in
> > +++ b/util/grub.d/10_linux.in
> > @@ -207,6 +207,30 @@ while [ "x$list" != "x" ] ; do
> > fi
> > done
> >
> > + # check if host is xen pv domU
> > + if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then
> > + dmi=/sys/class/dmi/id
> > + if [ -r "${dmi}/product_name" -a -r "${dmi}/sys_vendor" ]; then
> > + product_name=`cat ${dmi}/product_name`
> > + sys_vendor=`cat ${dmi}/sys_vendor`
> > + if test "${sys_vendor}" = "Xen" -a "${product_name}" = "HVM domU"; then
> > + # host is xen HVM guest
> > + xen_pv_domU=false
> > + fi
> > + fi
> > + else
> > + xen_pv_domU=false
> > + fi
> > +
> Please don't determine system type at config file generation. Think of
> e.g. systems that can be bootable in either configuration. Use $grub_cpu
> and $grub_platofem runtime variables.
The question is the config could be loaded by pygrub. It's unclear to me
in this case whether $grub_platform runtime variable will be set or not.
> > + if test "$xen_pv_domU" = "false" ; then
> > + # prevent xen kernel without pv_opt support from booting
> > + if (grep -qx "CONFIG_XEN=y" "${config}" 2> /dev/null && ! grep -qx "CONFIG_PARAVIRT=y" "${config}" 2> /dev/null); then
> We're moving away from grepping in $config. Can you see if it can be
> integrated with grub_file?
Thanks for pointing me this, I'll try integrating the check into
grub-file utility.
regards,
Michael
> > + echo "Skip xenlinux kernel $linux" >&2
> > + list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
> > + continue
> > + fi
> > + fi
> > +
> > initramfs=
> > if test -n "${config}" ; then
> > initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
> > -- 1.7.3.4 _______________________________________________ Grub-devel
> > mailing list Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-23 6:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-18 8:58 [PATCH] fix booting xenlinux kerenl error not on a xen domain Michael Chang
2014-09-21 15:27 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-09-23 6:52 ` Michael Chang
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.