This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-devel] /etc/grub.d/09-xen for generating grub.cfg for hypervis

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] /etc/grub.d/09-xen for generating grub.cfg for hypervisor boot entries.
From: Bruce Edge <bruce.edge@xxxxxxxxx>
Date: Wed, 19 May 2010 15:23:37 -0700
Delivery-date: Wed, 19 May 2010 15:26:10 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=nu+zKv4sStK3ZLOiwpM0iAvEJAiIGcwRF2oQuQoni3k=; b=sbsyfcsftT0vLR/V/1BwlmpADk5Az1tqX3zm7vUU2f5Bsvnu1sG10GrSNAjCnFblzp Q7/ZqrBe91Ez3M5XWcXe045GUd1Bk458lo4x4DP+Ewc+oOFAvPGhw/KT19KySBGlo4i9 39aRIJS1xKDLw/PGMfLoYAqTYB1ExIlGrNSM0=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=Gq+VyWywrHscewVpPP/jPII/mHYq/1OqxFCDv9NCHUUBDexnFnEbL/24CMhCM7uLcm uSLOKFxLocj9ipIU9IBNGi6XmxIJ3zP9ZsGhVJyzwALREqSjbsHIbO2ET2z2sDo+vanQ 6yVw8kHN8SQi55YxH1Um2IWUzNj7TrDR9RArc=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4BF447C9.1060805@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <AANLkTingW_TH0NKssADO4xk0PbAbRDaXn6mbTXxEmqw6@xxxxxxxxxxxxxx> <4BF32FAB.7050900@xxxxxxxxxxxx> <AANLkTinZJ8O7X3wZd6hzkMIoltQdVAfjowsk4uEuxL9l@xxxxxxxxxxxxxx> <4BF41AD9.6050806@xxxxxxxxxxxx> <AANLkTilzNPl0BSemyJJXjB2YcjRVHk7ahWHBxwmn8ilR@xxxxxxxxxxxxxx> <4BF42426.3040606@xxxxxxxxxxxx> <4BF42943.6080105@xxxxxxxx> <4BF447C9.1060805@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
OK, here's the minor mod to only do this for Xen kernels as determined by DOM0=y in boot/config-*
Added header and switched from sh to bash to get param subst functionality because I'm too lazy to think about other options.

========================================= cut ================================
#!/bin/bash -e
#          FILE:  09_xen
#         USAGE:  update-grub ... with this in /etc/grub.d
#   DESCRIPTION: Generate grub2 boot stanza for Xen systems
#                               Xen boot entries are automatically added to grub.cfg
#                               The 09-... name prefix puts the Xen boot entries before 
#                               the linux kernel entries
#       OPTIONS:  ---
#  REQUIREMENTS:  --- grub2, Xen hypervisor
#          BUGS:  --- probably
#         NOTES:  --- Copied from 10_linux with a few hacks to make ir work for Xen.
#                                       Incorporated suggestions to only do this for valid dom0 kernels
#        AUTHOR:  Bruce Edge (BRE), bruce.edge@xxxxxxx 
#       COMPANY:  LSI
#       VERSION:  1.0
#       CREATED:  05/19/2010 02:32:34 PM PDT
#      REVISION:  ---

. ${libdir}/grub/update-grub_lib

if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then

# Source grub defaults
. /etc/default/grub

# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`

if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
    || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then

test_gt ()
  local a=`echo $1 | sed -e "s,.*/vmlinu[zx]-,,g;s/[._-]\(pre\|rc\|test\|git\|old\)/~\1/g"`
  local b=`echo $2 | sed -e "s,.*/vmlinu[zx]-,,g;s/[._-]\(pre\|rc\|test\|git\|old\)/~\1/g"`
  if [ "x$b" = "x" ] ; then
    return 0
  dpkg --compare-versions "$a" gt "$b"
  return $?

find_latest ()
  local a=""
  for i in $@ ; do
    if test_gt "$i" "$a" ; then
  echo "$a"

list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
        if grub_file_is_not_garbage "$i" && grep -q 'DOM0=y' ${i/vmlinu[xz]/config} ; then echo -n "$i " ; fi

while [ "x$list" != "x" ] ; do
  linux=`find_latest $list`
  echo "Found linux image: $linux" >&2
  basename=`basename $linux`
  dirname=`dirname $linux`
  rel_dirname=`make_system_path_relative_to_its_root $dirname`
  version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
  alt_version=`echo $version | sed -e "s,\.old$,,g"`

  for i in "initrd.img-${version}" "initrd-${version}.img" \
           "initrd.img-${alt_version}" "initrd-${alt_version}.img"; do
    if test -e "${dirname}/${i}" ; then
  if test -n "${initrd}" ; then
    echo "Found initrd image: ${dirname}/${initrd}" >&2
    # "UUID=" magic is parsed by initrds.  Since there's no initrd, it can't work here.

  cat << EOF
  insmod lvm
  set root=(system-dom0_0)
menuentry "Xen ${OS}, linux ${version}" {
        multiboot dummy=dummy /boot/xen.gz $GRUB_CMDLINE_XEN_DEFAULT
        module ${rel_dirname}/${basename} root=${linux_root_device_thisversion} $GRUB_CMDLINE_LINUX_DEFAULT
  if test -n "${initrd}" ; then
    cat << EOF
        module ${rel_dirname}/${initrd} ${rel_dirname}/${initrd}
  cat << EOF

  list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`

========================================= cut ================================

On Wed, May 19, 2010 at 1:19 PM, Richie <listmail@xxxxxxxxxxxx> wrote:
Ok.  Thanks for correcting my mistake.

Jeremy Fitzhardinge wrote:
On 05/19/2010 10:47 AM, listmail wrote:
Yes that should do it and no corresponding boot/config-$(uname -r)
means nothing will be generated for the respective kernel.  There
could also be a check for CONFIG_XEN=y to support Xenlinux kernels. That entry should not exist in pvops .config    

Yes, it does.  CONFIG_XEN is the master switch for all Xen-related
features in a pvops kernel.  You would have to look for the absence of
CONFIG_PARAVIRT to detect a Xenlinux kernel.


Xen-devel mailing list

Xen-devel mailing list