From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>,
philmd@redhat.com, Markus Armbruster <armbru@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>
Subject: [PATCH 2/4] python/machine.py: remove bare except
Date: Thu, 28 May 2020 18:21:27 -0400 [thread overview]
Message-ID: <20200528222129.23826-3-jsnow@redhat.com> (raw)
In-Reply-To: <20200528222129.23826-1-jsnow@redhat.com>
Catch only the timeout error; if there are other problems, allow the
stack trace to be visible.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
python/qemu/machine.py | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index b9a98e2c862..e3ea5235713 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -342,7 +342,26 @@ def wait(self):
self._load_io_log()
self._post_shutdown()
- def shutdown(self, has_quit=False):
+ def _issue_shutdown(self, has_quit: bool = False) -> None:
+ """
+ Shutdown the VM.
+ """
+ if not self.is_running():
+ return
+
+ if self._qmp is not None:
+ if not has_quit:
+ self._qmp.cmd('quit')
+ self._qmp.close()
+
+ try:
+ self._popen.wait(timeout=3)
+ except subprocess.TimeoutExpired:
+ self._popen.kill()
+
+ self._popen.wait()
+
+ def shutdown(self, has_quit: bool = False) -> None:
"""
Terminate the VM and clean up
"""
@@ -353,17 +372,7 @@ def shutdown(self, has_quit=False):
self._console_socket.close()
self._console_socket = None
- if self.is_running():
- if self._qmp:
- try:
- if not has_quit:
- self._qmp.cmd('quit')
- self._qmp.close()
- self._popen.wait(timeout=3)
- except:
- self._popen.kill()
- self._popen.wait()
-
+ self._issue_shutdown(has_quit)
self._load_io_log()
self._post_shutdown()
--
2.21.3
next prev parent reply other threads:[~2020-05-28 22:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-28 22:21 [PATCH 0/4] python: pylint and flake8 support John Snow
2020-05-28 22:21 ` [PATCH 1/4] scripts/qmp: Fix shebang and imports John Snow
2020-05-28 22:21 ` John Snow [this message]
2020-05-28 22:21 ` [PATCH 3/4] python/qemu: delint and add pylintrc John Snow
2020-05-28 22:21 ` [PATCH 4/4] python/qemu: delint; add flake8 config John Snow
2020-05-30 19:33 ` [PATCH 0/4] python: pylint and flake8 support Philippe Mathieu-Daudé
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=20200528222129.23826-3-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=philmd@redhat.com \
--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).