mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
qemu-iotests: fix cleanup of background processes
Commit 934659c
switched the iotests to run qemu and qemu-nbd from a bash
subshell, in order to catch segfaults. Unfortunately, this means the
process PID cannot be captured via '$!'. We stopped killing qemu and
qemu-nbd processes, leaving a lot of orphaned, running qemu processes
after executing iotests.
Since the process is using exec in the subshell, the PID is the
same as the subshell PID.
Track these PIDs for cleanup using pidfiles in the $TEST_DIR. Only
track the qemu PID, however, if requested - not all usage requires
killing the process.
Reported-by: John Snow <jsnow@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Message-id: 9e4f958b3895b7259b98d845bb46f000ba362869.1446232490.git.jcody@redhat.com
[mreitz@redhat.com: Replaced '! -z "..."' by '-n "..."']
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
a9ecfa004f
commit
f6c8c2e055
4 changed files with 37 additions and 15 deletions
|
@ -30,8 +30,6 @@ QEMU_COMM_TIMEOUT=10
|
|||
QEMU_FIFO_IN="${TEST_DIR}/qmp-in-$$"
|
||||
QEMU_FIFO_OUT="${TEST_DIR}/qmp-out-$$"
|
||||
|
||||
QEMU_PID=
|
||||
_QEMU_HANDLE=0
|
||||
QEMU_HANDLE=0
|
||||
|
||||
# If bash version is >= 4.1, these will be overwritten and dynamic
|
||||
|
@ -153,11 +151,11 @@ function _launch_qemu()
|
|||
mkfifo "${fifo_out}"
|
||||
mkfifo "${fifo_in}"
|
||||
|
||||
QEMU_NEED_PID='y'\
|
||||
${QEMU} -nographic -serial none ${comm} -machine accel=qtest "${@}" \
|
||||
>"${fifo_out}" \
|
||||
2>&1 \
|
||||
<"${fifo_in}" &
|
||||
QEMU_PID[${_QEMU_HANDLE}]=$!
|
||||
|
||||
if [[ "${BASH_VERSINFO[0]}" -ge "5" ||
|
||||
("${BASH_VERSINFO[0]}" -ge "4" && "${BASH_VERSINFO[1]}" -ge "1") ]]
|
||||
|
@ -196,10 +194,18 @@ function _cleanup_qemu()
|
|||
# QEMU_PID[], QEMU_IN[], QEMU_OUT[] all use same indices
|
||||
for i in "${!QEMU_OUT[@]}"
|
||||
do
|
||||
if [ -z "${wait}" ]; then
|
||||
kill -KILL ${QEMU_PID[$i]} 2>/dev/null
|
||||
local QEMU_PID
|
||||
if [ -f "${TEST_DIR}/qemu-${i}.pid" ]; then
|
||||
read QEMU_PID < "${TEST_DIR}/qemu-${i}.pid"
|
||||
rm -f "${TEST_DIR}/qemu-${i}.pid"
|
||||
if [ -z "${wait}" ] && [ -n "${QEMU_PID}" ]; then
|
||||
kill -KILL ${QEMU_PID} 2>/dev/null
|
||||
fi
|
||||
if [ -n "${QEMU_PID}" ]; then
|
||||
wait ${QEMU_PID} 2>/dev/null # silent kill
|
||||
fi
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue