Skip to content

Commit 316db58

Browse files
committed
torture: Avoid duplicate specification of qemu command
Currently, the qemu command is constructed twice, once to dump it to the qemu-cmd file and again to execute it. This is of course an accident waiting to happen, but is done to ensure that the remainder of the script has an accurate idea of the running qemu command's PID. This commit therefore places both the qemu command and the PID capture into a new temporary file and sources that temporary file. Thus the single construction of the qemu command into the qemu-cmd file suffices for both purposes. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 2102ad2 commit 316db58

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,16 @@ then
161161
touch $resdir/buildonly
162162
exit 0
163163
fi
164+
165+
# Decorate qemu-cmd with redirection, backgrounding, and PID capture
166+
sed -e 's/$/ 2>\&1 \&/' < $resdir/qemu-cmd > $T/qemu-cmd
167+
echo 'echo $! > $resdir/qemu_pid' >> $T/qemu-cmd
168+
169+
# In case qemu refuses to run...
164170
echo "NOTE: $QEMU either did not run or was interactive" > $resdir/console.log
165-
( $QEMU $qemu_args -m $TORTURE_QEMU_MEM -kernel $KERNEL -append "$qemu_append $boot_args" > $resdir/qemu-output 2>&1 & echo $! > $resdir/qemu_pid; wait `cat $resdir/qemu_pid`; echo $? > $resdir/qemu-retval ) &
171+
172+
# Attempt to run qemu
173+
( . $T/qemu-cmd; wait `cat $resdir/qemu_pid`; echo $? > $resdir/qemu-retval ) &
166174
commandcompleted=0
167175
sleep 10 # Give qemu's pid a chance to reach the file
168176
if test -s "$resdir/qemu_pid"

0 commit comments

Comments
 (0)