From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: John Snow <jsnow@redhat.com>, Beraldo Leal <bleal@redhat.com>,
Cleber Rosa <crosa@redhat.com>
Subject: [PATCH 2/2] python/machine: Handle termination cases without QMP
Date: Mon, 24 Oct 2022 15:53:55 -0400 [thread overview]
Message-ID: <20221024195355.860504-3-jsnow@redhat.com> (raw)
In-Reply-To: <20221024195355.860504-1-jsnow@redhat.com>
If we request a shutdown of a VM without a QMP console, we'll just hang
waiting. Not ideal.
Add in code that attempts graceful termination in these cases. Tested
lightly; it appears to work and I doubt we rely on this case anywhere,
but it's a corner you're allowed to wedge yourself in, so it should be
handled.
Signed-off-by: John Snow <jsnow@redhat.com>
---
python/qemu/machine/machine.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index c467f951d5d..e1ba5d01b86 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -544,6 +544,12 @@ def _soft_shutdown(self, timeout: Optional[int]) -> None:
finally:
# Regardless, we want to quiesce the connection.
self._close_qmp_connection()
+ elif not self._quit_issued:
+ LOG.debug(
+ "Not anticipating QEMU quit and no QMP connection present, "
+ "issuing SIGTERM"
+ )
+ self._subp.terminate()
# May raise subprocess.TimeoutExpired
self._subp.wait(timeout=timeout)
--
2.37.3
prev parent reply other threads:[~2022-10-24 19:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 19:53 [PATCH 0/2] python: misc machine.py improvements John Snow
2022-10-24 19:53 ` [PATCH 1/2] python/machine: Add debug logging to key state changes John Snow
2022-10-25 8:24 ` Daniel P. Berrangé
2022-10-25 21:48 ` John Snow
2022-10-24 19:53 ` John Snow [this message]
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=20221024195355.860504-3-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=bleal@redhat.com \
--cc=crosa@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).