diff -r ffa5b2975dff -r e769a9931ec0 tools/xm-test/README --- a/tools/xm-test/README Fri Aug 4 19:34:44 2006 +++ b/tools/xm-test/README Mon Aug 7 11:20:18 2006 @@ -76,12 +76,8 @@ # ./configure --enable-hvm-support # make -The ramdisk/bin/create_disk_image script, which builds the full virt -disk.img, requires Lilo 22.7+ to be installed on the system. Lilo is -used to install the bootloader on the disk.img. - -If HVM support is enabled, the ramdisk/bin/create_disk_image script -will be run to create a full virt disk.img in the ramdisk directory. The +If HVM support is enabled, the ramdisk/bin/create_iso_image script +will be run to create a full virt disk.iso in the ramdisk directory. The script, by default, will look in /boot for the first non-Xen kernel it runs across. If you'd like to set xm-test to use a specific kernel, rather than the first one it finds in /boot, you can configure it in @@ -94,23 +90,16 @@ Otherwise, you can always rerun the create script using the -k option to use a specific kernel. -The disk.img created for HVM testing must contain a pcnet32 driver for -network tests. The ramdisk/bin/create_disk_image script will, by default, -look in the /lib/modules directory associated with the kernel being -used. If you'd like to specify a different location for the driver or -want to tell the script that the driver is built into the kernel, please -use the "--with-driver-dir=DRVDIR" configure option. If built into -the kernel, please use the key word "builtin" with the option: - -# ./autogen -# ./configure --enable-hvm-support --with-driver-dir=builtin -- or - -# ./configure --enable-hvm-support --with-driver-dir=/driver/directory -# make - -Xm-test will look for disk.img in the ramdisk directory when run by +The disk.iso created for HVM testing must contain a driver for network +tests. The default set of driver modules copied to the disk.iso +should include this. If not, to change the set of driver modules +copied to the disk.iso, use the "--with-hvm-modules=MODULES" option. + +The ramdisk/bin/create_iso_image script will look for modules in the +/lib/modules directory associated with the kernel being used. + +Xm-test will look for disk.iso in the ramdisk directory when run by default. - Running ======= diff -r ffa5b2975dff -r e769a9931ec0 tools/xm-test/configure.ac --- a/tools/xm-test/configure.ac Fri Aug 4 19:34:44 2006 +++ b/tools/xm-test/configure.ac Mon Aug 7 11:20:18 2006 @@ -69,28 +69,20 @@ AC_SUBST(NETMASK) AC_ARG_WITH(hvm-kernel, - [[ --with-hvm-kernel=kernel Use this kernel for hvm disk.img testing]], - HVMKERNEL=$withval, - HVMKERNEL="no") + [ --with-hvm-kernel=kernel Use this kernel for hvm disk.iso testing ], + [ HVMKERNEL="$withval" ], + [ HVMKERNEL="default" ]) dnl substitute @HVMKERNEL@ in all Makefiles AC_SUBST(HVMKERNEL) -AC_ARG_WITH(driver-dir, - [[ --with-driver-dir=drvdir Look in this directory for the pcnet32 driver for the vmx disk.img. drvdir can equal key word "builtin" if driver is built into the kernel]], - DRVDIR=$withval, - DRVDIR="no") +AC_ARG_WITH(hvm-modules, + [ --with-hvm-modules=modules Use these modules for hvm disk.iso testing [[default="8139too"]]], + [ HVMMODULES="$withval" ], + [ HVMMODULES="'8139too af_packet'" ]) -dnl substitute @DRVDIR@ in all Makefiles -AC_SUBST(DRVDIR) - -NETDRV="8139too.ko" -AC_ARG_WITH(network-drv, - [ --with-network-drv=driver Set network driver to use [[default="8139too.ko"]]], - [ NETDRV="$withval" ]) - -dnl substitute @DRVDIR@ in all Makefiles -AC_SUBST(NETDRV) +dnl substitute @HVMMODULES@ in all Makefiles +AC_SUBST(HVMMODULES) AC_SUBST(TENV) AC_SUBST(PACKAGE_VERSION) diff -r ffa5b2975dff -r e769a9931ec0 tools/xm-test/lib/XmTestLib/XenDomain.py --- a/tools/xm-test/lib/XmTestLib/XenDomain.py Fri Aug 4 19:34:44 2006 +++ b/tools/xm-test/lib/XmTestLib/XenDomain.py Mon Aug 7 11:20:18 2006 @@ -76,8 +76,8 @@ "vcpus" : 1, "acpi" : 0, "apic" : 0, - "disk" : ["file:%s/disk.img,ioemu:%s,w!" % - (getRdPath(), BLOCK_ROOT_DEV)], + "disk" : "file:%s/disk.iso,hdc:cdrom,r" % getRdPath(), + "boot" : "d", "kernel" : "/usr/lib/xen/boot/hvmloader", "builder" : "hvm", "sdl" : 0, diff -r ffa5b2975dff -r e769a9931ec0 tools/xm-test/ramdisk/Makefile.am --- a/tools/xm-test/ramdisk/Makefile.am Fri Aug 4 19:34:44 2006 +++ b/tools/xm-test/ramdisk/Makefile.am Mon Aug 7 11:20:18 2006 @@ -10,7 +10,7 @@ BR_ROOT = build_i386/root -HVM_SCRIPT = bin/create_disk_image +HVM_SCRIPT = bin/create_iso_image XMTEST_MAJ_VER = $(shell echo @PACKAGE_VERSION@ | perl -pe 's/(\d+)\.(\d+)\.\d+/\1.\2/') XMTEST_VER_IMG = initrd-$(XMTEST_MAJ_VER).img @@ -18,7 +18,7 @@ EXTRA_ROOT_DIRS = sys if HVM -all: initrd.img disk.img +all: initrd.img disk.iso else all: initrd.img endif @@ -47,19 +47,10 @@ initrd.img: $(XMTEST_VER_IMG) ln -sf $(XMTEST_VER_IMG) initrd.img -disk.img: existing +disk.iso: existing chmod a+x $(HVM_SCRIPT) - @if test ! "$(HVMKERNEL)" = "no" -a ! "$(DRVDIR)" = "no"; then \ - $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -k $(HVMKERNEL) \ - -d $(DRVDIR) -n $(NETDRV); \ - elif test "$(HVMKERNEL)" = "no" -a ! "$(DRVDIR)" = "no"; then \ - $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -d $(DRVDIR) -n $(NETDRV); \ - elif test ! "$(HVMKERNEL)" = "no" -a "$(DRVDIR)" = "no"; then \ - $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -k $(HVMKERNEL) \ - -n $(NETDRV); \ - else \ - $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -n $(NETDRV); \ - fi + $(HVM_SCRIPT) -r $(XMTEST_VER_IMG) -k $(HVMKERNEL) \ + -m $(HVMMODULES); existing: @if [ -n "$(INITRD)" ] && [ ! -f $(XMTEST_VER_IMG) ] ; then \ @@ -79,4 +70,4 @@ rm -f *~ rm -f initrd.img rm -f $(BR_TAR) - rm -f disk.img + rm -f disk.iso diff -r ffa5b2975dff -r e769a9931ec0 tools/xm-test/ramdisk/bin/create_iso_image --- /dev/null Fri Aug 4 19:34:44 2006 +++ b/tools/xm-test/ramdisk/bin/create_iso_image Mon Aug 7 11:20:18 2006 @@ -0,0 +1,186 @@ +#!/bin/bash +############################################################################### +## +## Copyright (C) International Business Machines Corp., 2005, 2006 +## Author(s): Daniel Stekloff , +## Harry Butterworth +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; under version 2 of the License. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +############################################################################### + +function usage() +{ + cat < Image to create (default disk.iso). + -k|--kernel Kernel to use on image (default pick from /boot). + -m|--modules Modules to add to the image rootfs (default no modules). + -r|--rootfs Filesystem image to use as image rootfs. +EOT +} + +function initialize_globals() +{ + IMAGE="disk.iso" + KERNEL="default" + MODULES="" + ROOTFS="" +} + +function get_options() +{ + while [ $# -gt 0 ]; do + case $1 in + -i|--image) + shift + IMAGE=${1} + shift + ;; + -k|--kernel) + shift + KERNEL=${1} + shift + ;; + -m|--modules) + shift + MODULES=${1} + shift + ;; + -r|--rootfs) + shift + ROOTFS=${1} + shift + ;; + *) + usage + exit 1 + ;; + esac + done +} + +function get_kernel_pathname() +{ + if test "$KERNEL" = "default"; then + # look in /boot for an existing kernel + local -a kernels=( `ls /boot | grep vmlinuz` ) + local k + + for k in ${kernels[@]}; do + case "$k" in + *xen*) + continue + ;; + *) + KERNEL="/boot/$k" + echo "Using kernel $KERNEL" + break + ;; + esac + done + fi + if test "$KERNEL" = "default"; then + echo "Couldn't find a kernel to use" + exit 1 + fi +} + +function put_grub_in_iso() +{ + mkdir -p $TMP/iso/boot/grub + cp /lib/grub/*/stage2_eltorito $TMP/iso/boot/grub +} + +function put_kernel_in_iso() +{ + mkdir -p $TMP/iso/boot + cp "$KERNEL" $TMP/iso/boot/ +} + +function unpack_rootfs() +{ + mkdir -p $TMP/mnt + mount -o loop $ROOTFS $TMP/mnt + cp -a $TMP/mnt $TMP/rootfs + umount $TMP/mnt +} + +function put_init_in_rootfs() +{ + (cd $TMP/rootfs/ && ln -sf linuxrc init) +} + +function put_module_and_deps_in_rootfs() +{ + mkdir -p $TMP/rootfs/lib/modules + local version=$( echo `basename $KERNEL` | sed 's/^vmlinuz-//' ) + for i in `modprobe --set-version $version --show-depends $1 2>/dev/null | sed -n 's%^insmod \([^ ]\+\).*%\1%p'`; do + cp $i $TMP/rootfs/lib/modules/`basename $i` + echo "insmod /lib/modules/`basename $i`" >> $TMP/rootfs/etc/init.d/rcS + done +} + +function put_modules_in_rootfs() +{ + for i in $MODULES; do + put_module_and_deps_in_rootfs $i + done +} + +function put_rootfs_in_iso() +{ + (cd $TMP/rootfs/ && find . | cpio --quiet -o -H newc | \ + gzip -9 > $TMP/iso/boot/rootfs.img) +} + +function put_grub_menu_in_iso() +{ + cat <<-EOT > "$TMP/iso/boot/grub/menu.lst" + default 0 + timeout 1 + title domU + kernel /boot/`basename $KERNEL` console=tty0 console=ttyS0 + initrd /boot/rootfs.img + boot + EOT +} + +function create_image() +{ + mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \ + -boot-load-size 4 -boot-info-table -o $IMAGE $TMP/iso +} + +initialize_globals + +get_options "$@" + +get_kernel_pathname + +TMP=`mktemp -t -d xm-test.XXXXXX` && { + put_grub_in_iso + put_kernel_in_iso + unpack_rootfs + put_init_in_rootfs + put_modules_in_rootfs + put_rootfs_in_iso + put_grub_menu_in_iso + create_image + rm -fr $TMP +} diff -r ffa5b2975dff -r e769a9931ec0 tools/xm-test/ramdisk/bin/create_disk_image --- a/tools/xm-test/ramdisk/bin/create_disk_image Fri Aug 4 19:34:44 2006 +++ /dev/null Mon Aug 7 11:20:18 2006 @@ -1,384 +0,0 @@ -#!/bin/bash -############################################################################### -## -## Copyright (C) International Business Machines Corp., 2005 -## Author(s): Daniel Stekloff -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; under version 2 of the License. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -## -############################################################################### -function cleanup() -{ - umount "$MNT" - rm -Rf "$MNT"; - if [ "$LOOPD" ]; then - losetup -d $LOOPD - fi - if [ "$LOOPP" ]; then - losetup -d $LOOPP - fi - if [ -e "$IMAGE" ]; then - rm -f "$IMAGE" - fi - if [ -e "$LCONF" ]; then - rm -f "$LCONF" - fi -} - -function die() -{ - cleanup - echo "$@" - exit 1 -} - -function usage() -{ - cat << EOU -Command creates a hvm guest disk image for xm-test. - -Usage: $0 [OPTIONS] - -OPTIONS: - -d|--dvrdir Directory where to find network driver - to use for disk image. - -i|--image Image name to create. - -k|--kernel Kernel name to use for disk image. - -n|--netdrv Network driver name to use for disk image. - -r|--rootfs Rootfs image to use for disk image. - -This script defaults to using the 8139too.ko driver for network tests. -If a dvrdir isn't added on the command-line, it will look in -/lib/modules/ directory relating to the supplied kernel. If the -network driver is built into the kernel, you can specify the key word -"builtin" with the -d option and the script will continue. - -Note: Many network drivers rely upon mii.ko. This script will look -for that module in the same location as the network driver, either -for the kernel or the location used with the -d option. - -EOU -} - -function check_dependencies() -{ - which lilo > /dev/null 2>&1 - if [ $? -ne 0 ]; then - die "$PROGNAME requires lilo version 22.7+ to be installed." - fi - local pass="$( lilo -V | cut -f3 -d " " | awk -F "." ' - { - if ($1 >= 22 && $2 >= 7) - print "true" - else - print "false" - }')" - if [ $pass = "false" ]; then - die "$PROGNAME requires lilo version 22.7+ to be installed." - fi -} - -function initialize_globals() -{ - PROGNAME="create_disk_image" - IMAGE="disk.img" - KERNEL="" - DRVDIR="" - NETDRV="8139too.ko" - LCONF="lilo.conf" - LOOPD="" # Loop device for entire disk image - LOOPP="" # Loop device for ext partition - ROOTFS="" - MNT="/tmp/$PROGNAME-mnt" - SIZE=8192 - SECTORS=32 - HEADS=8 - CYLINDERS=$(($SIZE/$SECTORS/$HEADS*2)) - BSIZE=$(($SIZE-$SECTORS)) - OFFSET=$(($SECTORS*512)) -} - -function get_options() -{ - while [ $# -gt 0 ]; do - case $1 in - -d|--drvdir) - shift - DRVDIR=${1} - shift - ;; - -i|--image) - shift - IMAGE=${1} - shift - ;; - -k|--kernel) - shift - KERNEL=${1} - shift - ;; - -n|--netdrv) - shift - NETDRV=${1} - shift - ;; - -r|--rootfs) - shift - ROOTFS=${1} - shift - ;; - *) - usage - exit 1 - ;; - esac - done -} - -function get_loopd() -{ - local loop - - for i in `seq 0 7`; do - losetup /dev/loop$i > /dev/null 2>&1 - if [ $? -ne 0 ]; then - # found one - echo $i - return 0 - fi - done - die "No free loopback devices." -} - -function losetup_image() -{ - local loop=$1 - shift - - # If offset, then associate with it - if [ $# -eq 1 ]; then - losetup -o $1 $loop $IMAGE - else - losetup $loop $IMAGE - fi - - if [ $? -ne 0 ]; then - die "Failed to losetup $IMAGE to $loop." - fi - - echo "Associated $IMAGE with $loop" -} - -function create_disk_image() -{ - dd bs=1024 count=$SIZE of=$IMAGE if=/dev/zero - - fdisk -b 512 -C $CYLINDERS -H $HEADS -S $SECTORS "$IMAGE" > /dev/null 2>&1 << EOF -n -p -1 -1 - -a -1 -w -EOF -} - -function makefs_image() -{ - mke2fs -N 24 -b 1024 $LOOPP $BSIZE - - if [ $? -ne 0 ]; then - die "mke2fs $LOOPP failed." - fi -} - -function dd_rootfs_to_image() -{ - if [ ! "$ROOTFS" ]; then - die "Must specify rootfs image to use." - fi - - dd if="$ROOTFS" of="$LOOPP" > /dev/null 2>&1 - if [ $? -ne 0 ]; then - die "Failed to dd $ROOTFS to $LOOPP." - fi - - # Resize fs to use full partition - e2fsck -f $LOOPP - resize2fs $LOOPP - if [ $? -ne 0 ]; then - die "Failed to resize rootfs on $LOOPP." - fi -} - -function get_kernel() -{ - # look in /boot for an existing kernel - local -a kernels=( `ls /boot | grep vmlinuz` ) - local k - - for k in ${kernels[@]}; do - case "$k" in - *xen*) - continue - ;; - *) - KERNEL="/boot/$k" - echo "Using kernel $KERNEL" - break - ;; - esac - done -} - -function copy_kernel_to_image() -{ - if [ ! "$KERNEL" ]; then - get_kernel || die "Couldn't find a kernel to use." - fi - - mkdir "$MNT/boot" - - cp "$KERNEL" "$MNT/boot" -} - -function copy_netdriver_to_image() -{ - local kernel=`basename $KERNEL` - local kversion=$( echo $kernel | sed 's/^vmlinuz-//' ) - local fdir="/lib/modules/$kversion/kernel/drivers/net" - - mkdir "$MNT/lib/modules" - if [ -e "$DRVDIR" ]; then - if [ -e "$DRVDIR/$NETDRV" ]; then - cp $DRVDIR/mii.ko $MNT/lib/modules - cp $DRVDIR/$NETDRV $MNT/lib/modules - else - die "Failed to find $NETDRV at $DRVDIR." - fi - elif [ -e "$fdir/$NETDRV" ]; then - cp $fdir/mii.ko $MNT/lib/modules - cp $fdir/$NETDRV $MNT/lib/modules - else - die "Xm-test requires at minimum the 8139too.ko driver to run." - fi - - # Make sure that modules will be installed - if [ -e "$MNT/etc/init.d/rcS" ]; then - echo "insmod /lib/modules/mii.ko" >> $MNT/etc/init.d/rcS - echo "insmod /lib/modules/$NETDRV" >> $MNT/etc/init.d/rcS - else - die "Failed to add insmod command to rcS file on image." - fi -} - -function lilo_image() -{ - local kernel=`basename $KERNEL` - - ( - cat < "/$MNT/boot/$LCONF" -} - -function install_lilo() -{ - lilo -C "$MNT/boot/$LCONF" - if [ $? -ne 0 ]; then - die "Failed to install $MNT/boot/$LCONF." - fi -} - -function add_getty_to_inittab() -{ - local itab=$MNT/etc/inittab - - if [ -e "$itab" ]; then - echo "# Start getty on serial line" >> $itab - echo "S0:12345:respawn:/sbin/getty ttyS0" >> $itab - fi -} - - -# Main starts here -initialize_globals -check_dependencies - -get_options "$@" - -create_disk_image - -# Get the first free loop device -ldev=$(get_loopd) -LOOPD="/dev/loop$ldev" -losetup_image $LOOPD - -# Now associate where the partition will go -ldev=$(get_loopd) -LOOPP="/dev/loop$ldev" -losetup_image $LOOPP $OFFSET - -makefs_image - -dd_rootfs_to_image - -if [ -e "$MNT" ]; then - rm -Rf "$MNT" -fi - -mkdir "$MNT"; -if [ $? -ne 0 ]; then - die "Failed to create temporary mount point $MNT." -fi - -mount "$LOOPP" "$MNT"; -if [ $? -ne 0 ]; then - die "Failed to mount $LOOPP on $MNT." -fi - -copy_kernel_to_image -if [ ! "$DRVDIR" = "builtin" ]; then - copy_netdriver_to_image -fi -#add_getty_to_inittab - -lilo_image -install_lilo - -umount "$MNT" -rm -Rf "$MNT"; - -losetup -d $LOOPD -losetup -d $LOOPP - -exit 0