From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>, "Kevin Wolf" <kwolf@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
qemu-block@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
"Max Reitz" <mreitz@redhat.com>, "John Snow" <jsnow@redhat.com>,
"Cleber Rosa" <crosa@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [Qemu-devel] [RFC PATCH v2 3/3] QEMUMachine: Don't suppress stack traces on close
Date: Thu, 27 Jun 2019 17:28:16 -0400 [thread overview]
Message-ID: <20190627212816.27298-4-jsnow@redhat.com> (raw)
In-Reply-To: <20190627212816.27298-1-jsnow@redhat.com>
We do need to run cleanup, but we should re-raise the error.
Rename _post_shutdown to _shutdown_cleanup, then use the
_post_shutdown name for the routine that will always run
at the conclusion of the shutdown() method.
Signed-off-by: John Snow <jsnow@redhat.com>
---
python/qemu/machine.py | 41 +++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 49445e675b..b36f0c3ef9 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -264,7 +264,8 @@ class QEMUMachine(object):
def _post_launch(self):
self._qmp.accept()
- def _post_shutdown(self):
+ def _shutdown_cleanup(self):
+ self._load_io_log()
if self._qemu_log_file is not None:
self._qemu_log_file.close()
self._qemu_log_file = None
@@ -326,8 +327,20 @@ class QEMUMachine(object):
"""
self._popen.wait()
self._qmp.close()
- self._load_io_log()
- self._post_shutdown()
+ self._shutdown_cleanup()
+
+ def _post_shutdown(self):
+ self._shutdown_cleanup()
+ exitcode = self.exitcode()
+ if exitcode is not None and exitcode < 0:
+ 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 shutdown(self):
"""
@@ -339,21 +352,13 @@ class QEMUMachine(object):
self._qmp.close()
except:
self._popen.kill()
- self._popen.wait()
-
- self._load_io_log()
- self._post_shutdown()
-
- exitcode = self.exitcode()
- if exitcode is not None and exitcode < 0:
- msg = 'qemu received signal %i: %s'
- if self._qemu_full_args:
- command = ' '.join(self._qemu_full_args)
- else:
- command = ''
- LOG.warning(msg, -exitcode, command)
-
- self._launched = False
+ # Don't hide exceptions from crashes
+ raise
+ finally:
+ self._popen.wait()
+ self._post_shutdown()
+ else:
+ self._post_shutdown()
def qmp(self, cmd, conv_keys=True, **args):
"""
--
2.21.0
next prev parent reply other threads:[~2019-06-27 21:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-27 21:28 [Qemu-devel] [RFC PATCH v2 0/3] python: refactor qemu/__init__.py John Snow
2019-06-27 21:28 ` [Qemu-devel] [RFC PATCH v2 1/3] python/qemu: split QEMUMachine out from underneath __init__.py John Snow
2019-06-28 16:05 ` Wainer dos Santos Moschetta
2019-07-01 23:20 ` John Snow
2019-06-27 21:28 ` [Qemu-devel] [RFC PATCH v2 2/3] machine.py: minor delinting John Snow
2019-06-27 21:28 ` John Snow [this message]
2019-06-27 21:32 ` [Qemu-devel] [RFC PATCH v2 0/3] python: refactor qemu/__init__.py John Snow
2019-07-01 21:27 ` Eduardo Habkost
2019-07-01 23:17 ` John Snow
2019-07-01 23:36 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190627212816.27298-4-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).