python/qemu: Kill QEMU process if 'quit' doesn't work
commitcd87f5e3783a16ea5ae631855d7bb89116adf0c3
authorKevin Wolf <kwolf@redhat.com>
Fri, 13 Mar 2020 08:36:16 +0000 (13 09:36 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Sat, 21 Mar 2020 22:37:32 +0000 (21 22:37 +0000)
tree61431af1907e803ac265c64377a929b1e80f6206
parentaa1cbeb86b4a44774b16042e2e84f236fc93c7db
python/qemu: Kill QEMU process if 'quit' doesn't work

With a QEMU bug, it can happen that the QEMU process doesn't react to a
'quit' QMP command. If we got an exception during previous QMP
communication (e.g. iotests Timeout expiring), we could also be in an
inconsistent state where after sending 'quit' we immediately read an old
response and close the socket even though the 'quit' command wasn't
processed yet. Both cases would lead to a hanging test.

Fix this by waiting for the QEMU process to exit after sending 'quit'
with a timeout, and if it doesn't happen within three seconds, send
SIGKILL.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200313083617.8326-3-kwolf@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
python/qemu/machine.py