aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2016-03-28 17:44:42 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2016-03-31 16:39:53 -0400
commitfb2c66af10f92bc83659c4d8a32e02287f0e5dda (patch)
tree2243adf34ac6948db82f587bd6320713a6ae6461
parent9eb5188a0704bd21eb7e4aef83b904fad43d3ec8 (diff)
torture: Kill qemu, not parent process
The current hang-check machinery in the rcutorture scripts uses "$!" of a parenthesized bash statement to capture the pid. Unfortunately, this captures not qemu's pid, but rather that of its parent that implements the parenthesized statement. This commit therefore adjusts things so as to capture qemu's actual pid, which then allows the script to actually kill qemu in event of a kernel hang. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
-rwxr-xr-xtools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh30
1 files changed, 24 insertions, 6 deletions
diff --git a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
index 0f80eefb0bfd..2eb8fefbe7d9 100755
--- a/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
+++ b/tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh
@@ -168,14 +168,25 @@ then
168fi 168fi
169echo "NOTE: $QEMU either did not run or was interactive" > $resdir/console.log 169echo "NOTE: $QEMU either did not run or was interactive" > $resdir/console.log
170echo $QEMU $qemu_args -m 512 -kernel $resdir/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd 170echo $QEMU $qemu_args -m 512 -kernel $resdir/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
171( $QEMU $qemu_args -m 512 -kernel $resdir/bzImage -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) & 171( $QEMU $qemu_args -m 512 -kernel $resdir/bzImage -append "$qemu_append $boot_args"& echo $! > $resdir/qemu_pid; wait `cat $resdir/qemu_pid`; echo $? > $resdir/qemu-retval ) &
172qemu_pid=$!
173commandcompleted=0 172commandcompleted=0
174echo Monitoring qemu job at pid $qemu_pid 173sleep 10 # Give qemu's pid a chance to reach the file
174if test -s "$resdir/qemu_pid"
175then
176 qemu_pid=`cat "$resdir/qemu_pid"`
177 echo Monitoring qemu job at pid $qemu_pid
178else
179 qemu_pid=""
180 echo Monitoring qemu job at yet-as-unknown pid
181fi
175while : 182while :
176do 183do
184 if test -z "$qemu_pid" -a -s "$resdir/qemu_pid"
185 then
186 qemu_pid=`cat "$resdir/qemu_pid"`
187 fi
177 kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` 188 kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
178 if kill -0 $qemu_pid > /dev/null 2>&1 189 if test -z "$qemu_pid" || kill -0 "$qemu_pid" > /dev/null 2>&1
179 then 190 then
180 if test $kruntime -ge $seconds 191 if test $kruntime -ge $seconds
181 then 192 then
@@ -195,12 +206,16 @@ do
195 ps -fp $killpid >> $resdir/Warnings 2>&1 206 ps -fp $killpid >> $resdir/Warnings 2>&1
196 fi 207 fi
197 else 208 else
198 echo ' ---' `date`: Kernel done 209 echo ' ---' `date`: "Kernel done"
199 fi 210 fi
200 break 211 break
201 fi 212 fi
202done 213done
203if test $commandcompleted -eq 0 214if test -z "$qemu_pid" -a -s "$resdir/qemu_pid"
215then
216 qemu_pid=`cat "$resdir/qemu_pid"`
217fi
218if test $commandcompleted -eq 0 -a -n "$qemu_pid"
204then 219then
205 echo Grace period for qemu job at pid $qemu_pid 220 echo Grace period for qemu job at pid $qemu_pid
206 while : 221 while :
@@ -220,6 +235,9 @@ then
220 fi 235 fi
221 sleep 1 236 sleep 1
222 done 237 done
238elif test -z "$qemu_pid"
239then
240 echo Unknown PID, cannot kill qemu command
223fi 241fi
224 242
225parse-torture.sh $resdir/console.log $title 243parse-torture.sh $resdir/console.log $title