aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2020-07-10 01:06:38 -0400
committerPhilippe Mathieu-Daudé <philmd@redhat.com>2020-07-14 22:22:22 +0200
commit14661d93d787846833b0e62d5995195c8851f741 (patch)
tree9758e374da803afae0ff0f268d7b9362efad3ddb /python
parent01afa757b6f1b8c7858cc29b8332e9fb6aa1e16f (diff)
python/machine.py: consolidate _post_shutdown()
Move more cleanup actions into _post_shutdown. As a change, if QEMU should so happen to be terminated during a call to wait(), that event will now be logged. This is not likely to occur during normative use. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Tested-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200710050649.32434-2-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'python')
-rw-r--r--python/qemu/machine.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index c25f0b42cf..ca1f2114e6 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -294,6 +294,8 @@ class QEMUMachine:
self._qmp.accept()
def _post_shutdown(self):
+ self._load_io_log()
+
if self._qemu_log_file is not None:
self._qemu_log_file.close()
self._qemu_log_file = None
@@ -307,6 +309,17 @@ class QEMUMachine:
while len(self._remove_files) > 0:
self._remove_if_exists(self._remove_files.pop())
+ exitcode = self.exitcode()
+ if exitcode is not None and exitcode < 0:
+ msg = 'qemu received signal %i; command: "%s"'
+ if self._qemu_full_args:
+ command = ' '.join(self._qemu_full_args)
+ else:
+ command = ''
+ LOG.warning(msg, -int(exitcode), command)
+
+ self._launched = False
+
def launch(self):
"""
Launch the VM and make sure we cleanup and expose the
@@ -355,7 +368,6 @@ class QEMUMachine:
self._popen.wait()
if self._qmp:
self._qmp.close()
- self._load_io_log()
self._post_shutdown()
def shutdown(self, has_quit=False, hard=False):
@@ -382,21 +394,8 @@ class QEMUMachine:
self._popen.kill()
self._popen.wait()
- self._load_io_log()
self._post_shutdown()
- exitcode = self.exitcode()
- if exitcode is not None and exitcode < 0 and \
- not (exitcode == -9 and hard):
- msg = 'qemu received signal %i: %s'
- if self._qemu_full_args:
- command = ' '.join(self._qemu_full_args)
- else:
- command = ''
- LOG.warning(msg, -int(exitcode), command)
-
- self._launched = False
-
def kill(self):
self.shutdown(hard=True)