From cd87f5e3783a16ea5ae631855d7bb89116adf0c3 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 13 Mar 2020 09:36:16 +0100 Subject: [PATCH] python/qemu: Kill QEMU process if 'quit' doesn't work MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: John Snow Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-id: 20200313083617.8326-3-kwolf@redhat.com Signed-off-by: Peter Maydell --- python/qemu/machine.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index f53abfa492..b9a98e2c86 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -359,6 +359,7 @@ class QEMUMachine(object): if not has_quit: self._qmp.cmd('quit') self._qmp.close() + self._popen.wait(timeout=3) except: self._popen.kill() self._popen.wait() -- 2.11.4.GIT