aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Nelson <dnelson@redhat.com>2010-09-28 05:25:19 +0200
committerAndi Kleen <ak@linux.intel.com>2010-09-28 05:25:19 +0200
commitdcfa4b811cdcb12ad26089d090cce88a31d29a4e (patch)
tree52576d3b4aabd0cc4be242f00669ad3219047a24
parente0ca7f239bbf7dd4afdb25309762a86b63a3aa31 (diff)
downloadmce-test-dcfa4b811cdcb12ad26089d090cce88a31d29a4e.tar.gz
KVM test fixes
This patch makes the following changes to the mce-test suite's kvm test. (git://git.kernel.org/pub/scm/utils/cpu/mce/mce-test.git) . Re-enable the late kill option (-l) on host_run.sh. . Add a virtual guest RAM size option (-m) to host_run.sh that gets passed to qemu-system-x86_64. This allows for testing guest's >= 4069M in size. . Allow for guest .img files to consist of LVM partitions. Signed-off-by: Dean Nelson <dnelson@redhat.com> Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r--kvm/host/host_run.sh89
1 files changed, 75 insertions, 14 deletions
diff --git a/kvm/host/host_run.sh b/kvm/host/host_run.sh
index 10884d0..a72f0d5 100644
--- a/kvm/host/host_run.sh
+++ b/kvm/host/host_run.sh
@@ -28,6 +28,7 @@ GUEST_DIR="/test"
host_key_pub="$HOST_DIR/id_rsa.pub"
host_key_priv="$HOST_DIR/id_rsa"
early_kill="1"
+RAM_size=""
kernel=""
initrd=""
@@ -50,8 +51,10 @@ usage()
echo -e "\t\t\tBy default, host privite key is $host_key_priv"
echo -e "\t-o offset\t: guest image offset (optional) "
echo -e "\t\t\tBy default, offset is calculated by kpartx "
- echo -e "\t-l latekill\t: disable early kill in guest system"
+ echo -e "\t-l\t\t: late kill, disable early kill in guest system"
echo -e "\t\t\tBy default, earlykill is enabled "
+ echo -e "\t-m ramsize\t: virtual RAM size of guest system"
+ echo -e "\t\t\tBy default, qemu-kvm defaults to 128M bytes"
echo "============If you want to specify the guest kernel==========="
echo "============please set below options all together============="
echo -e "\t-k kernel\t: guest kernel"
@@ -60,10 +63,10 @@ usage()
exit 0
}
-while getopts ":i:f:d:g:o:b:p:k:n:r:h:l" option
+while getopts ":i:f:d:g:o:b:p:k:n:r:h:lm:" option
do
case $option in
- i) image=$OPTARG; offset=`kpartx -l $image | awk '{print $NF*512}'`;;
+ i) image=$OPTARG; offset=`kpartx -l $image | awk '/loop deleted/ {next}; {offset=$NF*512}; END {print offset}'`;;
f) mce_inject_file=$OPTARG;;
d) HOST_DIR=$OPTARG; host_key_pub=$HOST_DIR/id_rsa.pub; host_key_priv=$HOST_DIR/id_rsa;;
g) GUEST_DIR=$OPTARG;;
@@ -74,6 +77,7 @@ do
k) kernel=$OPTARG;;
n) initrd=$OPTARG;;
r) root=$OPTARG;;
+ m) RAM_size="-m $OPTARG";;
h) usage;;
*) echo "invalid option!"; usage;;
esac
@@ -116,17 +120,74 @@ check_env()
chmod 600 $host_key_priv
}
-#Guest Image Preparation
-image_prepare()
+mount_image()
{
mnt=`mktemp -d`
- mount -oloop,offset=$offset $image $mnt && echo "mount image to $mnt "
+ mount_err=`mount -oloop,offset=$offset $image $mnt 2>&1`
+ if [ $? -eq 0 ]; then
+ fs_type=unset
+ echo "mount image to $mnt"
+ return 0
+ fi
+
+ #See if we're dealing with a LVM filesystem type
+ fs_type=`echo $mount_err | awk '/^mount: unknown filesystem type/ {print $NF}'`
+ if [ $fs_type != "'LVM2_member'" ]; then
+ echo unknown filesystem type
+ rm -rf $mnt
+ return 1
+ fi
+
+ #Try mounting the LVM image
+ loop_dev=`losetup -o ${offset} -f --show ${image}`
+ if [ -z ${loop_dev} ]; then
+ echo no available loop device
+ rm -rf $mnt
+ return 1
+ fi
+ vg=`pvdisplay ${loop_dev} | awk '/ VG Name/ {print $NF}'`
+ lv=lv_root
+ vgchange -a ey ${vg}
+ if [ ! -b /dev/mapper/${vg}-${lv} ]; then
+ echo ! block special
+ losetup -d ${loop_dev}
+ rm -rf $mnt
+ return 1
+ fi
+ mount /dev/mapper/${vg}-${lv} $mnt
if [ $? -ne 0 ]; then
- echo "mount image failed!"
+ vgchange -a en ${vg}
+ losetup -d ${loop_dev}
+ rm -rf $mnt
return 1
fi
+ echo "mount LVM image to $mnt"
+ return 0
+}
+
+umount_image()
+{
+ umount $mnt
+ sleep 2
+ if [ $fs_type = "'LVM2_member'" ]; then
+ vgchange -a en ${vg}
+ losetup -d ${loop_dev}
+ fi
+ rm -rf $mnt
+}
- [ ! -e $mnt$guest_script ] && umount $mnt && invalid "Invalid guest directory!"
+#Guest Image Preparation
+image_prepare()
+{
+ mount_image
+ if [ $? -ne 0 ]; then
+ echo "mount of image failed!"
+ return 1
+ fi
+ if [ ! -e $mnt$guest_script ]; then
+ umount_image
+ invalid "Invalid guest directory!"
+ fi
rm -f $mnt/etc/rc3.d/S99kvm_ras
rm -f $mnt$guest_tmp $mnt$guest_page
@@ -140,9 +201,7 @@ image_prepare()
chmod a+x $mnt$kvm_ras
ln -s $kvm_ras $mnt/etc/rc3.d/S99kvm_ras
sleep 2
- umount $mnt
- sleep 2
- rm -rf $mnt
+ umount_image
return 0
}
@@ -155,8 +214,8 @@ start_guest()
if [ ! -z $root ]; then
append="root=$root ro loglevel=8 mce=3 console=ttyS0,115200n8 console=tty0"
qemu-system-x86_64 -hda $image -kernel $kernel -initrd $initrd --append "$append" \
- -net nic,model=rtl8139 -net user,hostfwd=tcp::5555-:22 -monitor pty -serial pty \
- -pidfile $pid_file > $host_start 2>&1 &
+ $RAM_size -net nic,model=rtl8139 -net user,hostfwd=tcp::5555-:22 \
+ -monitor pty -serial pty -pidfile $pid_file > $host_start 2>&1 &
sleep 5
else
invalid "please specify the guest root partition!"
@@ -166,7 +225,8 @@ start_guest()
fi
else
echo "Start the default kernel on guest system"
- qemu-system-x86_64 -hda $image -net nic,model=rtl8139 -net user,hostfwd=tcp::5555-:22 \
+ qemu-system-x86_64 -hda $image \
+ $RAM_size -net nic,model=rtl8139 -net user,hostfwd=tcp::5555-:22 \
-monitor pty -serial pty -pidfile $pid_file > $host_start 2>&1 &
sleep 5
fi
@@ -225,6 +285,7 @@ error_inj()
#Inject SRAO error
cat $mce_inject_file > $mce_inject_data
echo "ADDR $ADDR" >> $mce_inject_data
+ echo "calling mce-inject $mce_inject_data"
mce-inject $mce_inject_data
}