# HG changeset patch # User stekloff@xxxxxxxxxxxxxxxxxxxxxxxxxx # Node ID 6f9ab9f4c148607d709539e19d27616b4a1cd3c0 # Parent 6687e156d6e7c3ca68f5b94e84055c383423027c Adding network testing support for xm-test with hvm. 1) Added capability for create_disk_image script to copy pcnet32 driver to disk.img. Added new cmdline option so can specify driver directory. 2) Added configuration --with-driver-dir=DVRDIR option so can specify where driver is at configure time. "builtin" keyword lets specify that driver is built into kernel. 3) Updated Makefile.am to build with new options. 4) Updated README to reflect changes. Signed-off-by: Daniel Stekloff diff -r 6687e156d6e7 -r 6f9ab9f4c148 tools/xm-test/README --- a/tools/xm-test/README Fri Jan 27 18:45:41 2006 +++ b/tools/xm-test/README Fri Jan 27 18:51:33 2006 @@ -54,6 +54,10 @@ you should not attempt to use a ramdisk from a previous minor version of xm-test (i.e., don't use a ramdisk from 0.4.0 with 0.5.0. 0.5.0 should work for 0.5.3 though) + + +BUILDING with HVM Support +========================= If you'd like to build and run this with hardware virtual machine assist (HVM) support to test fully virtualized disk images on VMX hardware, @@ -81,6 +85,20 @@ 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-vmx-support --with-driver-dir=builtin +- or - +# ./configure --enable-vmx-support --with-driver-dir=/driver/directory +# make + Xm-test will look for disk.img in the ramdisk directory when run by default. diff -r 6687e156d6e7 -r 6f9ab9f4c148 tools/xm-test/configure.ac --- a/tools/xm-test/configure.ac Fri Jan 27 18:45:41 2006 +++ b/tools/xm-test/configure.ac Fri Jan 27 18:51:33 2006 @@ -46,6 +46,14 @@ dnl substitute @VMXKERNEL@ in all Makefiles AC_SUBST(VMXKERNEL) +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") + +dnl substitute @DRVDIR@ in all Makefiles +AC_SUBST(DRVDIR) + AC_SUBST(TENV) AC_SUBST(PACKAGE_VERSION) diff -r 6687e156d6e7 -r 6f9ab9f4c148 tools/xm-test/ramdisk/Makefile.am --- a/tools/xm-test/ramdisk/Makefile.am Fri Jan 27 18:45:41 2006 +++ b/tools/xm-test/ramdisk/Makefile.am Fri Jan 27 18:51:33 2006 @@ -45,10 +45,15 @@ disk.img: $(XMTEST_VER_IMG) chmod a+x $(VMX_SCRIPT) - @if test "$(VMXKERNEL)" = "no" ; then \ + @if test ! "$(VMXKERNEL)" = "no" -a ! "$(DRVDIR)" = "no"; then \ + $(VMX_SCRIPT) -r $(XMTEST_VER_IMG) -k $(VMXKERNEL) \ + -d $(DRVDIR); \ + elif test "$(VMXKERNEL)" = "no" -a ! "$(DRVDIR)" = "no"; then \ + $(VMX_SCRIPT) -r $(XMTEST_VER_IMG) -d $(DRVDIR); \ + elif test ! "$(VMXKERNEL)" = "no" -a "$(DRVDIR)" = "no"; then \ + $(VMX_SCRIPT) -r $(XMTEST_VER_IMG) -k $(VMXKERNEL); \ + else \ $(VMX_SCRIPT) -r $(XMTEST_VER_IMG); \ - else \ - $(VMX_SCRIPT) -r $(XMTEST_VER_IMG) -k $(VMXKERNEL); \ fi existing: diff -r 6687e156d6e7 -r 6f9ab9f4c148 tools/xm-test/ramdisk/bin/create_disk_image --- a/tools/xm-test/ramdisk/bin/create_disk_image Fri Jan 27 18:45:41 2006 +++ b/tools/xm-test/ramdisk/bin/create_disk_image Fri Jan 27 18:51:33 2006 @@ -20,6 +20,8 @@ ############################################################################### function cleanup() { + umount "$MNT" + rm -Rf "$MNT"; if [ "$LOOPD" ]; then losetup -d $LOOPD fi @@ -49,9 +51,21 @@ Usage: $0 [OPTIONS] OPTIONS: + -d|--dvrdir Directory where to fine network driver + to use for disk image. -i|--image Image name to create. -k|--kernel Kernel name to use for disk image. -r|--rootfs Rootfs image to use for disk image. + +This script currently only supports the pcnet32 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: The pcnet32 driver relies upon mii.ko. This script will look +for that module in the same location as the pcnet32 driver, either +for the kernel or the location used with the -d option. EOU } @@ -79,6 +93,7 @@ PROGNAME="create_disk_image" IMAGE="disk.img" KERNEL="" + DRVDIR="" LCONF="lilo.conf" LOOPD="" # Loop device for entire disk image LOOPP="" # Loop device for ext partition @@ -96,6 +111,11 @@ { while [ $# -gt 0 ]; do case $1 in + -d|--drvdir) + shift + DRVDIR=${1} + shift + ;; -i|--image) shift IMAGE=${1} @@ -219,6 +239,36 @@ 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/pcnet32.ko" ]; then + cp $DRVDIR/mii.ko $MNT/lib/modules + cp $DRVDIR/pcnet32.ko $MNT/lib/modules + else + die "Failed to find pcnet32.ko at $DRVDIR." + fi + elif [ -e "$fdir/pcnet32.ko" ]; then + cp $fdir/mii.ko $MNT/lib/modules + cp $fdir/pcnet32.ko $MNT/lib/modules + else + die "Xm-test requires the pcnet32 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/pcnet32.ko" >> $MNT/etc/init.d/rcS + else + die "Failed to add insmod command to rcS file on image." + fi } function lilo_image() @@ -303,6 +353,9 @@ fi copy_kernel_to_image +if [ ! "$DRVDIR" = "builtin" ]; then + copy_netdriver_to_image +fi #add_getty_to_inittab lilo_image