Skip to content

Commit

Permalink
iotests: Add "wait" functionality to _cleanup_qemu
Browse files Browse the repository at this point in the history
The qemu process does not always need to be killed, just waiting for it
can be fine, too. This introduces a way to do so.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1423256778-3340-3-git-send-email-mreitz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
XanClic authored and stefanhaRH committed Feb 16, 2015
1 parent f53a829 commit ea82aa4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/qemu-iotests/common.qemu
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,23 @@ function _launch_qemu()


# Silenty kills the QEMU process
#
# If $wait is set to anything other than the empty string, the process will not
# be killed but only waited for, and any output will be forwarded to stdout. If
# $wait is empty, the process will be killed and all output will be suppressed.
function _cleanup_qemu()
{
# QEMU_PID[], QEMU_IN[], QEMU_OUT[] all use same indices
for i in "${!QEMU_OUT[@]}"
do
kill -KILL ${QEMU_PID[$i]} 2>/dev/null
if [ -z "${wait}" ]; then
kill -KILL ${QEMU_PID[$i]} 2>/dev/null
fi
wait ${QEMU_PID[$i]} 2>/dev/null # silent kill
if [ -n "${wait}" ]; then
cat <&${QEMU_OUT[$i]} | _filter_testdir | _filter_qemu \
| _filter_qemu_io | _filter_qmp
fi
rm -f "${QEMU_FIFO_IN}_${i}" "${QEMU_FIFO_OUT}_${i}"
eval "exec ${QEMU_IN[$i]}<&-" # close file descriptors
eval "exec ${QEMU_OUT[$i]}<&-"
Expand Down

0 comments on commit ea82aa4

Please sign in to comment.