Adding network testing support for xm-test with hvm.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sun, 29 Jan 2006 09:55:28 +0000 (10:55 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sun, 29 Jan 2006 09:55:28 +0000 (10:55 +0100)
 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 <dsteklof@us.ibm.com>
tools/xm-test/README
tools/xm-test/configure.ac
tools/xm-test/ramdisk/Makefile.am
tools/xm-test/ramdisk/bin/create_disk_image

index 7e8b5bef236a8855755c60b8be2f353dce4dedae..481baca2115631db88f2c5b9545820db68c59f96 100644 (file)
@@ -55,6 +55,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, 
 please add the --enable-vmx-support option to configure:
@@ -81,6 +85,20 @@ with the "--with-vmx-kernel=KERNEL" option:
 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.
 
index 30f4fd348df331064789b5a5718bbe87d9e7c650..8f844c1148e13b6b840d7f919bde06be9841b194 100644 (file)
@@ -46,6 +46,14 @@ AC_ARG_WITH(vmx-kernel,
 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)
 
index 216928bd428dc87644c6ff757d1d6a083b59ba26..21133f5c4e68ecefc8018b8c8ce5f148662fe658 100644 (file)
@@ -45,10 +45,15 @@ initrd.img: $(XMTEST_VER_IMG)
 
 disk.img: $(XMTEST_VER_IMG)
        chmod a+x $(VMX_SCRIPT)
-       @if test "$(VMXKERNEL)" = "no" ; then \
-               $(VMX_SCRIPT) -r $(XMTEST_VER_IMG); \
-       else \
+       @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); \
        fi
 
 existing:
index dad6d2494b3b9b9229744d9999e35df3f6fbec74..836e8a5c14d4ef748859ede2318f38adea6ca1cb 100644 (file)
@@ -20,6 +20,8 @@
 ###############################################################################
 function cleanup()
 {
+       umount "$MNT"
+       rm -Rf "$MNT";
        if [ "$LOOPD" ]; then
                losetup -d $LOOPD
        fi
@@ -49,10 +51,22 @@ Command creates a vmx guest disk image for xm-test.
 Usage: $0 [OPTIONS]
 
 OPTIONS:
+    -d|--dvrdir <name>       Directory where to fine network driver 
+                             to use for disk image. 
     -i|--image <name>        Image name to create.
     -k|--kernel <name>       Kernel name to use for disk image.
     -r|--rootfs <image>      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 @@ function initialize_globals()
        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 @@ function get_options()
 {
        while [ $# -gt 0 ]; do
                case $1 in
+                       -d|--drvdir)
+                               shift
+                               DRVDIR=${1}
+                               shift
+                               ;;
                        -i|--image)
                                shift
                                IMAGE=${1}
@@ -221,6 +241,36 @@ function copy_kernel_to_image()
        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()
 {
        local kernel=`basename $KERNEL`
@@ -303,6 +353,9 @@ if [ $? -ne 0 ]; then
 fi
 
 copy_kernel_to_image
+if [ ! "$DRVDIR" = "builtin" ]; then
+       copy_netdriver_to_image
+fi
 #add_getty_to_inittab
 
 lilo_image