WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

RE: [Xen-users] Startup-Hook Script ?

To: "'Fajar A. Nugraha'" <fajar@xxxxxxxxx>, <xen-users@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-users] Startup-Hook Script ?
From: "Steffen Heil" <lists@xxxxxxxxxxxxxxx>
Date: Tue, 1 Jul 2008 10:58:15 +0200
Cc:
Delivery-date: Tue, 01 Jul 2008 01:58:58 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <48699E2A.50208@xxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <2B0ECF0840E94D13A20529E641944A39@shs1> <20080627111443.F72458-100000@xxxxxxxxxxxxx><8E69D1B097DA4EF3BCD0302BB6E1EF5A@shs1> <48699E2A.50208@xxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcjbJwodt+8IpaAsReOqSJcDRQoYEQAMPCsg
Hi

> Since function-wise you're trying to achieve what pygrub 
> does, it might be easier to create another pygrub-like script 
> and put it as bootloader on your config file.
> ...
> Attached is bash script that MIGHT work you. This script does 
> not parse grub's config file, so you might need to manually 
> adjust ARGS at the top of the script as needed (my test works 
> fine with empty ARGS though).

Great idea. I didn't know I could implement bootloaders myself.
I merged my block-script with your bootloader-script and it works great.

I parses /boot/grub/menu.lst (inside the domUs-root-partition), reads
"kernel" and "ramdisk" path of the "default"-th entry in the configuration
list, copies those to the dom0, and returns appropiate paths to xen.
Last problem: The "exit 3" does not seem to work correctly. Whenever a
problem exists, xm create just hangs instead of stopping...

For anyone interested I have pasted it below.

Regards,
  Steffen




#!/bin/bash

arg_count=$#
device=${!arg_count}
args=""
output=""
until [ -z "$1" ]
do
  if [ ${1:0:7} = "--args=" ];then
    args=${1:7}
  elif [ ${1:0:9} = "--output=" ];then
    output=${1:9}
  fi
  shift
done

if [ -z "$args" ] || [ -z "$output" ] || [ ! -e "$device" ]
then
  exit 3
fi

mount="$output-mount"
mkdir "$mount"
mount -o ro "$device" "$mount"
if [ $? -gt 0 ];then
  rmdir "$mount"
  exit 3
fi

config=`awk 'BEGIN { x=-1 } $1=="default" { x=$2+1 } $1=="title" { x=x-1 }
  x==0 && $1=="kernel" && $2~/(\/[a-z0-9-]|[\\.a-z0-9-]*)*/ { kernel=$2 }
  x==0 && $1=="initrd" && $2~/(\/[a-z0-9-]|[\\.a-z0-9-]*)*/ { initrd=$2 }
  END { print kernel " " initrd }' < $mount/boot/grub/menu.lst`

kernel=${config% *}
initrd=${config#* }
if [ -z "$kernel" ] || [ -z "$initrd" ] || [ ! -e "$mount$kernel" ] || [ !
-e "$mount$initrd" ]
then
  umount "$mount"
  rmdir "$mount"
  exit 3
fi

echo "$device, $mount, $kernel, $initrd, $output" >>/block.log

cp "$mount$kernel" "$output-kernel"
cp "$mount$initrd" "$output-initrd"

umount "$mount"
rmdir "$mount"

echo -n "linux (kernel $output-kernel)(ramdisk $output-initrd)(args
\"$args\")" >> "$output"

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users
<Prev in Thread] Current Thread [Next in Thread>