From: Max Reitz Date: Fri, 19 Jul 2019 09:26:17 +0000 (+0200) Subject: iotests: Add @has_quit to vm.shutdown() X-Git-Tag: v4.1.0-rc2~8^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4687133b812323b743e490a21510a1e1ac0fb6df;p=thirdparty%2Fqemu.git iotests: Add @has_quit to vm.shutdown() If a test has issued a quit command already (which may be useful to do explicitly because the test wants to show its effects), QEMUMachine.shutdown() should not do so again. Otherwise, the VM may well return an ECONNRESET which will lead QEMUMachine.shutdown() to killing it, which then turns into a "qemu received signal 9" line. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 49445e675b8..128a3d1dc28 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -329,13 +329,14 @@ class QEMUMachine(object): self._load_io_log() self._post_shutdown() - def shutdown(self): + def shutdown(self, has_quit=False): """ Terminate the VM and clean up """ if self.is_running(): try: - self._qmp.cmd('quit') + if not has_quit: + self._qmp.cmd('quit') self._qmp.close() except: self._popen.kill() diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255 index 49433ec1228..3632d507d0d 100755 --- a/tests/qemu-iotests/255 +++ b/tests/qemu-iotests/255 @@ -132,4 +132,4 @@ with iotests.FilePath('src.qcow2') as src_path, \ vm.qmp_log('block-job-cancel', device='job0') vm.qmp_log('quit') - vm.shutdown() + vm.shutdown(has_quit=True)