python/machine: Handle termination cases without QMP

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>
This commit is contained in:
John Snow 2022-10-27 14:58:36 -04:00
parent 9cccb3305a
commit 3c6e5e8ce1

View file

@ -547,6 +547,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
LOG.debug(