aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Gong <gong.chen@linux.intel.com>2011-04-01 16:19:17 +0800
committerAndi Kleen <ak@linux.intel.com>2011-04-20 09:35:55 -0700
commit61252a69e3c16bf26adeeb6754c3714016228a18 (patch)
treeccb5a8301aac5965d95f7ad55d56aa241796a64d
parent94c973b73f6c1b948bb53a6a68465969a6e98c6b (diff)
downloadmce-test-61252a69e3c16bf26adeeb6754c3714016228a18.tar.gz
Some minor fixes for KVM SRAO test cases
Here is the list: 1) EARLYKILL is defined but not used 2) some echo info outside functions include "!", which will make shell confused and give wrong output 3) add page-types check on the host side 4) some $mnt usages are dangerous. Such as $mnt$get_tmp will return wrong path 5) fix a spell error for variable QEMU_PID 6) update p2v -> x-gpa2hva according to Ying's latest QEMU patch 7) in the usage host_run.sh can be executed directly but in fact it doesn't. Add execution permission for it. 8) add "-h" description and option "h" should not be given a ":" 9) make "-m" option a consistent action as other options 10) add more conditions check before tests 11) simplify some statements 12) auto mount mce_inject module Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
-rw-r--r--kvm/host/guest_init2
-rwxr-xr-x[-rw-r--r--]kvm/host/host_run.sh86
2 files changed, 61 insertions, 27 deletions
diff --git a/kvm/host/guest_init b/kvm/host/guest_init
index b16d2b4..df34ad6 100644
--- a/kvm/host/guest_init
+++ b/kvm/host/guest_init
@@ -11,7 +11,7 @@ start() {
touch /root/jobdone
mount -t debugfs null /sys/kernel/debug
echo 1 > /sys/kernel/debug/mce/fake_ser_p
- echo 1 > /proc/sys/vm/memory_failure_early_kill
+ echo EARLYKILL > /proc/sys/vm/memory_failure_early_kill
sh GUESTRUN &
return "$RETVAL"
}
diff --git a/kvm/host/host_run.sh b/kvm/host/host_run.sh
index a72f0d5..c90af86 100644..100755
--- a/kvm/host/host_run.sh
+++ b/kvm/host/host_run.sh
@@ -49,12 +49,13 @@ usage()
echo -e "\t\t\tBy default, host public key is $host_key_pub"
echo -e "\t-p privkey\t: host privite key"
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-o offset\t: guest image offset"
echo -e "\t\t\tBy default, offset is calculated by kpartx "
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 -e "\t\t\tBy default, qemu-kvm defaults to 512M bytes"
+ echo -e "\t-h\t\t: show this help"
echo "============If you want to specify the guest kernel==========="
echo "============please set below options all together============="
echo -e "\t-k kernel\t: guest kernel"
@@ -63,12 +64,14 @@ usage()
exit 0
}
-while getopts ":i:f:d:g:o:b:p:k:n:r:h:lm:" option
+while getopts "i:f:d:g:o:b:p:k:n:r:hlm:" option
do
case $option in
- i) image=$OPTARG; offset=`kpartx -l $image | awk '/loop deleted/ {next}; {offset=$NF*512}; END {print offset}'`;;
+ i) image=$OPTARG;;
f) mce_inject_file=$OPTARG;;
- d) HOST_DIR=$OPTARG; host_key_pub=$HOST_DIR/id_rsa.pub; host_key_priv=$HOST_DIR/id_rsa;;
+ d) HOST_DIR=$OPTARG
+ host_key_pub=$HOST_DIR/id_rsa.pub
+ host_key_priv=$HOST_DIR/id_rsa ;;
g) GUEST_DIR=$OPTARG;;
b) host_key_pub=$OPTARG;;
p) host_key_priv=$OPTARG;;
@@ -77,9 +80,9 @@ do
k) kernel=$OPTARG;;
n) initrd=$OPTARG;;
r) root=$OPTARG;;
- m) RAM_size="-m $OPTARG";;
+ m) RAM_size=$OPTARG;;
h) usage;;
- *) echo "invalid option!"; usage;;
+ *) echo 'invalid option!'; usage;;
esac
done
@@ -103,12 +106,33 @@ mce_inject_data=$HOST_DIR/mce_inject_data
invalid()
{
echo $1
- echo "Try \`./host_run.sh -h\` for more information."
+ echo "Try ./host_run.sh -h for more information."
exit 0
}
check_env()
{
+ if [ "`whoami`" != "root" ]; then
+ echo "Must run as root"
+ exit 1
+ fi
+
+ if modinfo mce_inject &> /dev/null; then
+ if ! lsmod | grep -q mce_inject; then
+ if ! modprobe mce_inject; then
+ invalid "module mce_inject isn't supported ?"
+ fi
+ fi
+ fi
+
+ which page-types &>/dev/null
+ [ ! $? -eq 0 ] && invalid "please install page-types tool!"
+ which kpartx &>/dev/null
+ [ ! $? -eq 0 ] && invalid "please install kpartx tool!"
+ which mce-inject &>/dev/null
+ [ ! $? -eq 0 ] && invalid "please install mce-inject tool!"
+
+ [ -z $RAM_size ] && RAM_size=512
[ -z $image ] && invalid "please input the guest image!"
[ ! -e $image ] && invalid "guest image $image does not exist!"
[ -z $mce_inject_file ] && invalid "please input the mce data file!"
@@ -123,6 +147,8 @@ check_env()
mount_image()
{
mnt=`mktemp -d`
+ offset=`kpartx -l $image | awk '/loop deleted/ {next}; \
+ {offset=$NF*512}; END {print offset}'`
mount_err=`mount -oloop,offset=$offset $image $mnt 2>&1`
if [ $? -eq 0 ]; then
fs_type=unset
@@ -138,6 +164,13 @@ mount_image()
return 1
fi
+ which losetup &>/dev/null
+ [ ! $? -eq 0 ] && invalid "please install losetup tool!"
+ which pvdisplay &>/dev/null
+ [ ! $? -eq 0 ] && invalid "please install pvdisplay tool!"
+ which vgchange &>/dev/null
+ [ ! $? -eq 0 ] && invalid "please install vgchange tool!"
+
#Try mounting the LVM image
loop_dev=`losetup -o ${offset} -f --show ${image}`
if [ -z ${loop_dev} ]; then
@@ -149,7 +182,7 @@ mount_image()
lv=lv_root
vgchange -a ey ${vg}
if [ ! -b /dev/mapper/${vg}-${lv} ]; then
- echo ! block special
+ echo '! block special'
losetup -d ${loop_dev}
rm -rf $mnt
return 1
@@ -181,15 +214,15 @@ image_prepare()
{
mount_image
if [ $? -ne 0 ]; then
- echo "mount of image failed!"
+ echo 'mount of image failed!'
return 1
fi
- if [ ! -e $mnt$guest_script ]; then
+ 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
+ rm -f $mnt/$guest_tmp $mnt/$guest_page
if [ ! -d $mnt/root/.ssh ]; then
mkdir $mnt/root/.ssh
@@ -197,8 +230,9 @@ image_prepare()
fi
cat $host_key_pub >> $mnt/root/.ssh/authorized_keys
kvm_ras=/etc/init.d/kvm_ras
- sed "s#EARLYKILL#$early_kill#g" $guest_init | sed "s#GUESTRUN#$guest_script#g" > $mnt$kvm_ras
- chmod a+x $mnt$kvm_ras
+ sed -e "s#EARLYKILL#$early_kill#g" \
+ -e "s#GUESTRUN#$guest_script#g" $guest_init > $mnt/$kvm_ras
+ chmod a+x $mnt/$kvm_ras
ln -s $kvm_ras $mnt/etc/rc3.d/S99kvm_ras
sleep 2
umount_image
@@ -214,7 +248,7 @@ 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" \
- $RAM_size -net nic,model=rtl8139 -net user,hostfwd=tcp::5555-:22 \
+ -m $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
@@ -226,13 +260,13 @@ start_guest()
else
echo "Start the default kernel on guest system"
qemu-system-x86_64 -hda $image \
- $RAM_size -net nic,model=rtl8139 -net user,hostfwd=tcp::5555-:22 \
+ -m $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
monitor_console=`awk '{print $NF}' $host_start | sed -n -e '1p'`
serial_console=`awk '{print $NF}' $host_start | sed -n -e '2p'`
- QUME_PID=`cat $pid_file`
+ QEMU_PID=`cat $pid_file`
echo "monitor console is $monitor_console"
echo "serial console is $serial_console"
echo "Waiting for guest system start up..."
@@ -267,14 +301,14 @@ addr_translate()
sleep 2
#Get Host virtual address
- echo p2v $GUEST_PHY > $monitor_console
+ echo x-gpa2hva $GUEST_PHY > $monitor_console
cat $monitor_console > $monitor_console_output &
sleep 5
HOST_VIRT=`awk '/address/{print $NF}' $monitor_console_output |cut -b 3-11`
echo "Host virtual address is $HOST_VIRT"
#Get Host physical address
- page-types/page-types -p $QUME_PID -LN -b anon | grep $HOST_VIRT > $host_tmp
+ page-types -p $QEMU_PID -LN -b anon | grep $HOST_VIRT > $host_tmp
sleep 5
ADDR=`cat $host_tmp | awk '{print "0x"$2"000"}' `
echo "Host physical address is $ADDR"
@@ -311,13 +345,13 @@ check_guest_klog()
check_env
image_prepare
if [ $? -ne 0 ]; then
- echo "Mount Guest image failed, quit testing!"
+ echo 'Mount Guest image failed, quit testing!'
else
start_guest
get_guest_klog
check_guest_alive
if [ $? -ne 0 ]; then
- echo "Start Guest system failed, quit testing!"
+ echo 'Start Guest system failed, quit testing!'
else
sleep 5
addr_translate
@@ -325,17 +359,17 @@ else
sleep 5
check_guest_klog
if [ $? -ne 0 ]; then
- echo "FAIL: Did not get expected log!"
- exit 0
+ echo 'FAIL: Did not get expected log!'
+ exit 1
else
- echo "PASS: Inject error into guest!"
+ echo 'PASS: Inject error into guest!'
fi
sleep 10
check_guest_alive
if [ $? -ne 0 ]; then
- echo "FAIL: Guest System could have died!"
+ echo 'FAIL: Guest System could have died!'
else
- echo "PASS: Guest System alive!"
+ echo 'PASS: Guest System alive!'
fi
fi
fi