1d3b1548aSPaul E. McKenney#!/bin/bash 2fef141f6SPaul E. McKenney# SPDX-License-Identifier: GPL-2.0+ 3d3b1548aSPaul E. McKenney# 4d3b1548aSPaul E. McKenney# Run a kvm-based test of the specified tree on the specified configs. 5d3b1548aSPaul E. McKenney# Fully automated run and error checking, no graphics console. 6d3b1548aSPaul E. McKenney# 7d3b1548aSPaul E. McKenney# Execute this in the source tree. Do not run it as a background task 8d3b1548aSPaul E. McKenney# because qemu does not seem to like that much. 9d3b1548aSPaul E. McKenney# 10*3c43ce53SPaul E. McKenney# Usage: kvm-test-1-run.sh config resdir seconds qemu-args boot_args_in 11d3b1548aSPaul E. McKenney# 121b2f48f2SBoqun Feng# qemu-args defaults to "-enable-kvm -nographic", along with arguments 131b2f48f2SBoqun Feng# specifying the number of CPUs and other options 141b2f48f2SBoqun Feng# generated from the underlying CPU architecture. 15a8dafbf3SPaul E. McKenney# boot_args_in defaults to value returned by the per_version_boot_params 16d3b1548aSPaul E. McKenney# shell function. 17d3b1548aSPaul E. McKenney# 18a8dafbf3SPaul E. McKenney# Anything you specify for either qemu-args or boot_args_in is appended to 19d3b1548aSPaul E. McKenney# the default values. The "-smp" value is deduced from the contents of 20d3b1548aSPaul E. McKenney# the config fragment. 21d3b1548aSPaul E. McKenney# 22d3b1548aSPaul E. McKenney# More sophisticated argument parsing is clearly needed. 23d3b1548aSPaul E. McKenney# 24d3b1548aSPaul E. McKenney# Copyright (C) IBM Corporation, 2011 25d3b1548aSPaul E. McKenney# 26fef141f6SPaul E. McKenney# Authors: Paul E. McKenney <paulmck@linux.ibm.com> 27d3b1548aSPaul E. McKenney 28b038c58bSPaul E. McKenneyT=${TMPDIR-/tmp}/kvm-test-1-run.sh.$$ 29d3b1548aSPaul E. McKenneytrap 'rm -rf $T' 0 30d62c9833SPaul E. McKenneymkdir $T 31d3b1548aSPaul E. McKenney 32feef2d28SSeongJae Park. functions.sh 33edae018dSPranith Kumar. $CONFIGFRAG/ver_functions.sh 34d3b1548aSPaul E. McKenney 35d3b1548aSPaul E. McKenneyconfig_template=${1} 36d3b1548aSPaul E. McKenneyconfig_dir=`echo $config_template | sed -e 's,/[^/]*$,,'` 37d3b1548aSPaul E. McKenneytitle=`echo $config_template | sed -e 's/^.*\///'` 38*3c43ce53SPaul E. McKenneyresdir=${2} 39d3b1548aSPaul E. McKenneyif test -z "$resdir" -o ! -d "$resdir" -o ! -w "$resdir" 40d3b1548aSPaul E. McKenneythen 41d3b1548aSPaul E. McKenney echo "kvm-test-1-run.sh :$resdir: Not a writable directory, cannot store results into it" 42d3b1548aSPaul E. McKenney exit 1 43d3b1548aSPaul E. McKenneyfi 44d3b1548aSPaul E. McKenneyecho ' ---' `date`: Starting build 45d3b1548aSPaul E. McKenneyecho ' ---' Kconfig fragment at: $config_template >> $resdir/log 46b5744d3cSPaul E. McKenneytouch $resdir/ConfigFragment.input 476be63d7dSPaul E. McKenney 48409670aaSPaul E. McKenney# Combine additional Kconfig options into an existing set such that 49409670aaSPaul E. McKenney# newer options win. The first argument is the Kconfig source ID, the 50409670aaSPaul E. McKenney# second the to-be-updated file within $T, and the third and final the 51409670aaSPaul E. McKenney# list of additional Kconfig options. Note that a $2.tmp file is 52409670aaSPaul E. McKenney# created when doing the update. 536be63d7dSPaul E. McKenneyconfig_override_param () { 54409670aaSPaul E. McKenney if test -n "$3" 556be63d7dSPaul E. McKenney then 56409670aaSPaul E. McKenney echo $3 | sed -e 's/^ *//' -e 's/ *$//' | tr -s " " "\012" > $T/Kconfig_args 576be63d7dSPaul E. McKenney echo " --- $1" >> $resdir/ConfigFragment.input 586be63d7dSPaul E. McKenney cat $T/Kconfig_args >> $resdir/ConfigFragment.input 59409670aaSPaul E. McKenney config_override.sh $T/$2 $T/Kconfig_args > $T/$2.tmp 60409670aaSPaul E. McKenney mv $T/$2.tmp $T/$2 616be63d7dSPaul E. McKenney # Note that "#CHECK#" is not permitted on commandline. 626be63d7dSPaul E. McKenney fi 636be63d7dSPaul E. McKenney} 646be63d7dSPaul E. McKenney 65409670aaSPaul E. McKenneyecho > $T/KcList 66409670aaSPaul E. McKenneyconfig_override_param "$config_dir/CFcommon" KcList "`cat $config_dir/CFcommon 2> /dev/null`" 67409670aaSPaul E. McKenneyconfig_override_param "$config_template" KcList "`cat $config_template 2> /dev/null`" 68b67a9170SPaul E. McKenneyconfig_override_param "--gdb options" KcList "$TORTURE_KCONFIG_GDB_ARG" 6904dbcdb4SPaul E. McKenneyconfig_override_param "--kasan options" KcList "$TORTURE_KCONFIG_KASAN_ARG" 70409670aaSPaul E. McKenneyconfig_override_param "--kcsan options" KcList "$TORTURE_KCONFIG_KCSAN_ARG" 71409670aaSPaul E. McKenneyconfig_override_param "--kconfig argument" KcList "$TORTURE_KCONFIG_ARG" 72409670aaSPaul E. McKenneycp $T/KcList $resdir/ConfigFragment 73d62c9833SPaul E. McKenney 74acc1adf5SPaul E. McKenneybase_resdir=`echo $resdir | sed -e 's/\.[0-9]\+$//'` 75a519d214SPaul E. McKenneyif test "$base_resdir" != "$resdir" && test -f $base_resdir/bzImage && test -f $base_resdir/vmlinux 76d3b1548aSPaul E. McKenneythen 77acc1adf5SPaul E. McKenney # Rerunning previous test, so use that test's kernel. 78acc1adf5SPaul E. McKenney QEMU="`identify_qemu $base_resdir/vmlinux`" 791b900c6aSBoqun Feng BOOT_IMAGE="`identify_boot_image $QEMU`" 801b900c6aSBoqun Feng KERNEL=$base_resdir/${BOOT_IMAGE##*/} # use the last component of ${BOOT_IMAGE} 81acc1adf5SPaul E. McKenney ln -s $base_resdir/Make*.out $resdir # for kvm-recheck.sh 82acc1adf5SPaul E. McKenney ln -s $base_resdir/.config $resdir # for kvm-recheck.sh 8385ef2bd2SPaul E. McKenney # Arch-independent indicator 8485ef2bd2SPaul E. McKenney touch $resdir/builtkernel 85a519d214SPaul E. McKenneyelif test "$base_resdir" != "$resdir" 86a519d214SPaul E. McKenneythen 87a519d214SPaul E. McKenney # Rerunning previous test for which build failed 88a519d214SPaul E. McKenney ln -s $base_resdir/Make*.out $resdir # for kvm-recheck.sh 89a519d214SPaul E. McKenney ln -s $base_resdir/.config $resdir # for kvm-recheck.sh 90a519d214SPaul E. McKenney echo Initial build failed, not running KVM, see $resdir. 91*3c43ce53SPaul E. McKenney if test -f $resdir/build.wait 92a519d214SPaul E. McKenney then 93*3c43ce53SPaul E. McKenney mv $resdir/build.wait $resdir/build.ready 94a519d214SPaul E. McKenney fi 95a519d214SPaul E. McKenney exit 1 96409670aaSPaul E. McKenneyelif kvm-build.sh $T/KcList $resdir 97acc1adf5SPaul E. McKenneythen 98acc1adf5SPaul E. McKenney # Had to build a kernel for this test. 996dc82595SPaul E. McKenney QEMU="`identify_qemu vmlinux`" 100f189cc8cSPaul E. McKenney BOOT_IMAGE="`identify_boot_image $QEMU`" 1016dc82595SPaul E. McKenney cp vmlinux $resdir 1026dc82595SPaul E. McKenney cp .config $resdir 1036dc82595SPaul E. McKenney cp Module.symvers $resdir > /dev/null || : 1046dc82595SPaul E. McKenney cp System.map $resdir > /dev/null || : 105f189cc8cSPaul E. McKenney if test -n "$BOOT_IMAGE" 106f189cc8cSPaul E. McKenney then 1076dc82595SPaul E. McKenney cp $BOOT_IMAGE $resdir 1081b900c6aSBoqun Feng KERNEL=$resdir/${BOOT_IMAGE##*/} 10985ef2bd2SPaul E. McKenney # Arch-independent indicator 11085ef2bd2SPaul E. McKenney touch $resdir/builtkernel 111f189cc8cSPaul E. McKenney else 112f189cc8cSPaul E. McKenney echo No identifiable boot image, not running KVM, see $resdir. 113f189cc8cSPaul E. McKenney echo Do the torture scripts know about your architecture? 114f189cc8cSPaul E. McKenney fi 115d3b1548aSPaul E. McKenney parse-build.sh $resdir/Make.out $title 116d3b1548aSPaul E. McKenneyelse 117acc1adf5SPaul E. McKenney # Build failed. 1186dc82595SPaul E. McKenney cp .config $resdir || : 119d3b1548aSPaul E. McKenney echo Build failed, not running KVM, see $resdir. 120*3c43ce53SPaul E. McKenney if test -f $resdir/build.wait 121d3b1548aSPaul E. McKenney then 122*3c43ce53SPaul E. McKenney mv $resdir/build.wait $resdir/build.ready 123d3b1548aSPaul E. McKenney fi 124d3b1548aSPaul E. McKenney exit 1 125d3b1548aSPaul E. McKenneyfi 126*3c43ce53SPaul E. McKenneyif test -f $resdir/build.wait 127acc1adf5SPaul E. McKenneythen 128*3c43ce53SPaul E. McKenney mv $resdir/build.wait $resdir/build.ready 129acc1adf5SPaul E. McKenneyfi 130*3c43ce53SPaul E. McKenneywhile test -f $resdir/build.ready 131d3b1548aSPaul E. McKenneydo 132d3b1548aSPaul E. McKenney sleep 1 133d3b1548aSPaul E. McKenneydone 134*3c43ce53SPaul E. McKenneyseconds=$3 135*3c43ce53SPaul E. McKenneyqemu_args=$4 136*3c43ce53SPaul E. McKenneyboot_args_in=$5 137d3b1548aSPaul E. McKenney 1389bee2c6fSPaul E. McKenneyif test -z "$TORTURE_BUILDONLY" 1399bee2c6fSPaul E. McKenneythen 140d3b1548aSPaul E. McKenney echo ' ---' `date`: Starting kernel 1419bee2c6fSPaul E. McKenneyfi 142d3b1548aSPaul E. McKenney 143d3b1548aSPaul E. McKenney# Generate -smp qemu argument. 1441b2f48f2SBoqun Fengqemu_args="-enable-kvm -nographic $qemu_args" 145d62c9833SPaul E. McKenneycpu_count=`configNR_CPUS.sh $resdir/ConfigFragment` 146a8dafbf3SPaul E. McKenneycpu_count=`configfrag_boot_cpus "$boot_args_in" "$config_template" "$cpu_count"` 147b22eb7ceSPaul E. McKenneyif test "$cpu_count" -gt "$TORTURE_ALLOTED_CPUS" 148d3b1548aSPaul E. McKenneythen 149b22eb7ceSPaul E. McKenney echo CPU count limited from $cpu_count to $TORTURE_ALLOTED_CPUS | tee -a $resdir/Warnings 150b22eb7ceSPaul E. McKenney cpu_count=$TORTURE_ALLOTED_CPUS 151d3b1548aSPaul E. McKenneyfi 152d3b1548aSPaul E. McKenneyqemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`" 15388513ae5SPaul E. McKenneyqemu_args="`specify_qemu_net "$qemu_args"`" 154d3b1548aSPaul E. McKenney 155d3b1548aSPaul E. McKenney# Generate architecture-specific and interaction-specific qemu arguments 156c979ff99SPaul E. McKenneyqemu_args="$qemu_args `identify_qemu_args "$QEMU" "$resdir/console.log"`" 157d3b1548aSPaul E. McKenney 158d3b1548aSPaul E. McKenney# Generate qemu -append arguments 159d3b1548aSPaul E. McKenneyqemu_append="`identify_qemu_append "$QEMU"`" 160d3b1548aSPaul E. McKenney 161d3b1548aSPaul E. McKenney# Pull in Kconfig-fragment boot parameters 162a8dafbf3SPaul E. McKenneyboot_args="`configfrag_boot_params "$boot_args_in" "$config_template"`" 163d3b1548aSPaul E. McKenney# Generate kernel-version-specific boot parameters 1646bb7ff17SPaul E. McKenneyboot_args="`per_version_boot_params "$boot_args" $resdir/.config $seconds`" 165b67a9170SPaul E. McKenneyif test -n "$TORTURE_BOOT_GDB_ARG" 166b67a9170SPaul E. McKenneythen 167b67a9170SPaul E. McKenney boot_args="$boot_args $TORTURE_BOOT_GDB_ARG" 168b67a9170SPaul E. McKenneyfi 169a8dafbf3SPaul E. McKenney 170a8dafbf3SPaul E. McKenney# Give bare-metal advice 171a8dafbf3SPaul E. McKenneymodprobe_args="`echo $boot_args | tr -s ' ' '\012' | grep "^$TORTURE_MOD\." | sed -e "s/$TORTURE_MOD\.//g"`" 172a8dafbf3SPaul E. McKenneykboot_args="`echo $boot_args | tr -s ' ' '\012' | grep -v "^$TORTURE_MOD\."`" 173a8dafbf3SPaul E. McKenneytestid_txt="`dirname $resdir`/testid.txt" 174a8dafbf3SPaul E. McKenneytouch $resdir/bare-metal 175a8dafbf3SPaul E. McKenneyecho To run this scenario on bare metal: >> $resdir/bare-metal 176a8dafbf3SPaul E. McKenneyecho >> $resdir/bare-metal 177a8dafbf3SPaul E. McKenneyecho " 1." Set your bare-metal build tree to the state shown in this file: >> $resdir/bare-metal 178a8dafbf3SPaul E. McKenneyecho " " $testid_txt >> $resdir/bare-metal 179a8dafbf3SPaul E. McKenneyecho " 2." Update your bare-metal build tree"'"s .config based on this file: >> $resdir/bare-metal 180a8dafbf3SPaul E. McKenneyecho " " $resdir/ConfigFragment >> $resdir/bare-metal 181a8dafbf3SPaul E. McKenneyecho " 3." Make the bare-metal kernel"'"s build system aware of your .config updates: >> $resdir/bare-metal 182a8dafbf3SPaul E. McKenneyecho " " $ 'yes "" | make oldconfig' >> $resdir/bare-metal 183a8dafbf3SPaul E. McKenneyecho " 4." Build your bare-metal kernel. >> $resdir/bare-metal 184a8dafbf3SPaul E. McKenneyecho " 5." Boot your bare-metal kernel with the following parameters: >> $resdir/bare-metal 185a8dafbf3SPaul E. McKenneyecho " " $kboot_args >> $resdir/bare-metal 186a8dafbf3SPaul E. McKenneyecho " 6." Start the test with the following command: >> $resdir/bare-metal 187a8dafbf3SPaul E. McKenneyecho " " $ modprobe $TORTURE_MOD $modprobe_args >> $resdir/bare-metal 188a8dafbf3SPaul E. McKenneyecho " 7." After some time, end the test with the following command: >> $resdir/bare-metal 189a8dafbf3SPaul E. McKenneyecho " " $ rmmod $TORTURE_MOD >> $resdir/bare-metal 190a8dafbf3SPaul E. McKenneyecho " 8." Copy your bare-metal kernel"'"s .config file, overwriting this file: >> $resdir/bare-metal 191a8dafbf3SPaul E. McKenneyecho " " $resdir/.config >> $resdir/bare-metal 192a8dafbf3SPaul E. McKenneyecho " 9." Copy the console output from just before the modprobe to just after >> $resdir/bare-metal 193a8dafbf3SPaul E. McKenneyecho " " the rmmod into this file: >> $resdir/bare-metal 194a8dafbf3SPaul E. McKenneyecho " " $resdir/console.log >> $resdir/bare-metal 195a8dafbf3SPaul E. McKenneyecho "10." Check for runtime errors using the following command: >> $resdir/bare-metal 196a8dafbf3SPaul E. McKenneyecho " " $ tools/testing/selftests/rcutorture/bin/kvm-recheck.sh `dirname $resdir` >> $resdir/bare-metal 197a8dafbf3SPaul E. McKenneyecho >> $resdir/bare-metal 198a8dafbf3SPaul E. McKenneyecho Some of the above steps may be skipped if you build your bare-metal >> $resdir/bare-metal 199a8dafbf3SPaul E. McKenneyecho kernel here: `head -n 1 $testid_txt | sed -e 's/^Build directory: //'` >> $resdir/bare-metal 200a8dafbf3SPaul E. McKenney 201b67a9170SPaul E. McKenneyecho $QEMU $qemu_args -m $TORTURE_QEMU_MEM -kernel $KERNEL -append \"$qemu_append $boot_args\" $TORTURE_QEMU_GDB_ARG > $resdir/qemu-cmd 202315957caSPaul E. McKenneyecho "# TORTURE_SHUTDOWN_GRACE=$TORTURE_SHUTDOWN_GRACE" >> $resdir/qemu-cmd 203315957caSPaul E. McKenneyecho "# seconds=$seconds" >> $resdir/qemu-cmd 204d3b1548aSPaul E. McKenney 205805ffee2SPaul E. McKenneyif test -n "$TORTURE_BUILDONLY" 206d3b1548aSPaul E. McKenneythen 207d3b1548aSPaul E. McKenney echo Build-only run specified, boot/test omitted. 2089bee2c6fSPaul E. McKenney touch $resdir/buildonly 209d3b1548aSPaul E. McKenney exit 0 210d3b1548aSPaul E. McKenneyfi 211316db589SPaul E. McKenney 212316db589SPaul E. McKenney# Decorate qemu-cmd with redirection, backgrounding, and PID capture 213316db589SPaul E. McKenneysed -e 's/$/ 2>\&1 \&/' < $resdir/qemu-cmd > $T/qemu-cmd 214316db589SPaul E. McKenneyecho 'echo $! > $resdir/qemu_pid' >> $T/qemu-cmd 215316db589SPaul E. McKenney 216316db589SPaul E. McKenney# In case qemu refuses to run... 217c979ff99SPaul E. McKenneyecho "NOTE: $QEMU either did not run or was interactive" > $resdir/console.log 218316db589SPaul E. McKenney 219316db589SPaul E. McKenney# Attempt to run qemu 220315957caSPaul E. McKenneykstarttime=`gawk 'BEGIN { print systime() }' < /dev/null` 221316db589SPaul E. McKenney( . $T/qemu-cmd; wait `cat $resdir/qemu_pid`; echo $? > $resdir/qemu-retval ) & 222d3b1548aSPaul E. McKenneycommandcompleted=0 223b67a9170SPaul E. McKenneyif test -z "$TORTURE_KCONFIG_GDB_ARG" 224b67a9170SPaul E. McKenneythen 225fb2c66afSPaul E. McKenney sleep 10 # Give qemu's pid a chance to reach the file 226fb2c66afSPaul E. McKenney if test -s "$resdir/qemu_pid" 227fb2c66afSPaul E. McKenney then 228fb2c66afSPaul E. McKenney qemu_pid=`cat "$resdir/qemu_pid"` 229d3b1548aSPaul E. McKenney echo Monitoring qemu job at pid $qemu_pid 230fb2c66afSPaul E. McKenney else 231fb2c66afSPaul E. McKenney qemu_pid="" 232fb2c66afSPaul E. McKenney echo Monitoring qemu job at yet-as-unknown pid 233fb2c66afSPaul E. McKenney fi 234b67a9170SPaul E. McKenneyfi 235b67a9170SPaul E. McKenneyif test -n "$TORTURE_KCONFIG_GDB_ARG" 236b67a9170SPaul E. McKenneythen 237b67a9170SPaul E. McKenney echo Waiting for you to attach a debug session, for example: > /dev/tty 238b67a9170SPaul E. McKenney echo " gdb $base_resdir/vmlinux" > /dev/tty 239b67a9170SPaul E. McKenney echo 'After symbols load and the "(gdb)" prompt appears:' > /dev/tty 240b67a9170SPaul E. McKenney echo " target remote :1234" > /dev/tty 241b67a9170SPaul E. McKenney echo " continue" > /dev/tty 242b67a9170SPaul E. McKenney kstarttime=`gawk 'BEGIN { print systime() }' < /dev/null` 243b67a9170SPaul E. McKenneyfi 2440bca7c33SPaul E. McKenneywhile : 245d3b1548aSPaul E. McKenneydo 246fb2c66afSPaul E. McKenney if test -z "$qemu_pid" -a -s "$resdir/qemu_pid" 247fb2c66afSPaul E. McKenney then 248fb2c66afSPaul E. McKenney qemu_pid=`cat "$resdir/qemu_pid"` 249fb2c66afSPaul E. McKenney fi 250c493f1c9SPaul E. McKenney kruntime=`gawk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` 251fb2c66afSPaul E. McKenney if test -z "$qemu_pid" || kill -0 "$qemu_pid" > /dev/null 2>&1 252d3b1548aSPaul E. McKenney then 25308c79742SPaul E. McKenney if test -n "$TORTURE_KCONFIG_GDB_ARG" 25408c79742SPaul E. McKenney then 25508c79742SPaul E. McKenney : 256c821f855SPaul E. McKenney elif test $kruntime -ge $seconds || test -f "$resdir/../STOP.1" 2570bca7c33SPaul E. McKenney then 2580bca7c33SPaul E. McKenney break; 2590bca7c33SPaul E. McKenney fi 260d3b1548aSPaul E. McKenney sleep 1 261d3b1548aSPaul E. McKenney else 262d3b1548aSPaul E. McKenney commandcompleted=1 263d3b1548aSPaul E. McKenney if test $kruntime -lt $seconds 264d3b1548aSPaul E. McKenney then 265d3b1548aSPaul E. McKenney echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1 266fff35c4eSPaul E. McKenney grep "^(qemu) qemu:" $resdir/kvm-test-1-run.sh.out >> $resdir/Warnings 2>&1 267fff35c4eSPaul E. McKenney killpid="`sed -n "s/^(qemu) qemu: terminating on signal [0-9]* from pid \([0-9]*\).*$/\1/p" $resdir/Warnings`" 268fff35c4eSPaul E. McKenney if test -n "$killpid" 269fff35c4eSPaul E. McKenney then 270fff35c4eSPaul E. McKenney echo "ps -fp $killpid" >> $resdir/Warnings 2>&1 271fff35c4eSPaul E. McKenney ps -fp $killpid >> $resdir/Warnings 2>&1 272fff35c4eSPaul E. McKenney fi 273c64659efSPaul E. McKenney # Reduce probability of PID reuse by allowing a one-minute buffer 274c64659efSPaul E. McKenney if test $((kruntime + 60)) -lt $seconds && test -s "$resdir/../jitter_pids" 275c64659efSPaul E. McKenney then 276c64659efSPaul E. McKenney awk < "$resdir/../jitter_pids" ' 277c64659efSPaul E. McKenney NF > 0 { 278c64659efSPaul E. McKenney pidlist = pidlist " " $1; 279c64659efSPaul E. McKenney n++; 280c64659efSPaul E. McKenney } 281c64659efSPaul E. McKenney END { 282c64659efSPaul E. McKenney if (n > 0) { 283c64659efSPaul E. McKenney print "kill " pidlist; 284c64659efSPaul E. McKenney } 285c64659efSPaul E. McKenney }' | sh 286c64659efSPaul E. McKenney fi 287d3b1548aSPaul E. McKenney else 288fb2c66afSPaul E. McKenney echo ' ---' `date`: "Kernel done" 289d3b1548aSPaul E. McKenney fi 290d3b1548aSPaul E. McKenney break 291d3b1548aSPaul E. McKenney fi 292d3b1548aSPaul E. McKenneydone 293fb2c66afSPaul E. McKenneyif test -z "$qemu_pid" -a -s "$resdir/qemu_pid" 294fb2c66afSPaul E. McKenneythen 295fb2c66afSPaul E. McKenney qemu_pid=`cat "$resdir/qemu_pid"` 296fb2c66afSPaul E. McKenneyfi 297fb2c66afSPaul E. McKenneyif test $commandcompleted -eq 0 -a -n "$qemu_pid" 298d3b1548aSPaul E. McKenneythen 299c821f855SPaul E. McKenney if ! test -f "$resdir/../STOP.1" 3006387ecbcSPaul E. McKenney then 301d3b1548aSPaul E. McKenney echo Grace period for qemu job at pid $qemu_pid 3026387ecbcSPaul E. McKenney fi 3036e8c66c8SPaul E. McKenney oldline="`tail $resdir/console.log`" 3040bca7c33SPaul E. McKenney while : 305d3b1548aSPaul E. McKenney do 306c821f855SPaul E. McKenney if test -f "$resdir/../STOP.1" 3076387ecbcSPaul E. McKenney then 308c821f855SPaul E. McKenney echo "PID $qemu_pid killed due to run STOP.1 request" >> $resdir/Warnings 2>&1 3096387ecbcSPaul E. McKenney kill -KILL $qemu_pid 3106387ecbcSPaul E. McKenney break 3116387ecbcSPaul E. McKenney fi 312c493f1c9SPaul E. McKenney kruntime=`gawk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` 313d3b1548aSPaul E. McKenney if kill -0 $qemu_pid > /dev/null 2>&1 314d3b1548aSPaul E. McKenney then 3150bca7c33SPaul E. McKenney : 316d3b1548aSPaul E. McKenney else 317d3b1548aSPaul E. McKenney break 318d3b1548aSPaul E. McKenney fi 3196e8c66c8SPaul E. McKenney must_continue=no 3206e8c66c8SPaul E. McKenney newline="`tail $resdir/console.log`" 3216e8c66c8SPaul E. McKenney if test "$newline" != "$oldline" && echo $newline | grep -q ' [0-9]\+us : ' 3226e8c66c8SPaul E. McKenney then 3236e8c66c8SPaul E. McKenney must_continue=yes 3246e8c66c8SPaul E. McKenney fi 3256e8c66c8SPaul E. McKenney last_ts="`tail $resdir/console.log | grep '^\[ *[0-9]\+\.[0-9]\+]' | tail -1 | sed -e 's/^\[ *//' -e 's/\..*$//'`" 3262c667e5eSPaul E. McKenney if test -z "$last_ts" 3276e8c66c8SPaul E. McKenney then 3286e8c66c8SPaul E. McKenney last_ts=0 3296e8c66c8SPaul E. McKenney fi 3306e8c66c8SPaul E. McKenney if test "$newline" != "$oldline" -a "$last_ts" -lt $((seconds + $TORTURE_SHUTDOWN_GRACE)) 3316e8c66c8SPaul E. McKenney then 3326e8c66c8SPaul E. McKenney must_continue=yes 3336e8c66c8SPaul E. McKenney fi 3346e8c66c8SPaul E. McKenney if test $must_continue = no -a $kruntime -ge $((seconds + $TORTURE_SHUTDOWN_GRACE)) 335d3b1548aSPaul E. McKenney then 336b7659241SPaul E. McKenney echo "!!! PID $qemu_pid hung at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1 337d3b1548aSPaul E. McKenney kill -KILL $qemu_pid 3380bca7c33SPaul E. McKenney break 339d3b1548aSPaul E. McKenney fi 3406e8c66c8SPaul E. McKenney oldline=$newline 3416e8c66c8SPaul E. McKenney sleep 10 342d3b1548aSPaul E. McKenney done 343fb2c66afSPaul E. McKenneyelif test -z "$qemu_pid" 344fb2c66afSPaul E. McKenneythen 345fb2c66afSPaul E. McKenney echo Unknown PID, cannot kill qemu command 346d3b1548aSPaul E. McKenneyfi 347d3b1548aSPaul E. McKenney 348d3b1548aSPaul E. McKenneyparse-console.sh $resdir/console.log $title 349