mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-16 01:03:31 +00:00
Python patch roundup
Mostly CI fixes and some small debugging improvements. -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAmO16doACgkQfe+BBqr8 OQ6CyBAAnJ3Opkz00uUNZIJndDCi9NdLAFEOYSlUQ/4Vx0WTphKRP/NSwfTsSymj ps6E6op0H8AL5PBDjVAF8CzGK9aHNhhDIahbein/42/OQo9uWWMlOnZYhwx8tfxS 8AuYk3s9HeLkSleSHGA0zJZhNB5BtYKewB9FYNZz07fk9wECAVmSOE20g6KR3Tec Fya+YRrvmjCxovGlxxFVi3c1B37bAS25hV5GlrSXxWtZcodIPUsyNEp03SuFjSj7 EvqrRXI3UdR2cSwd56BFyZJfgkKtoLjQMf/hTC8RPHej4SDnpFW8yuN1N3wiSJLn td+yfdIlqg95mF15a2qhwqp+xINWj2J277tkBwbF3FYwChKlJFavw/Ihv6SJIV0+ 7ddiJ/M6PIqsdkfL+//+oFP4Jnh3sW0T5Aa0AYTe/JSMzhLsiOV4H77PZKlylsIt yzNskXQTyGdjZBAQtabTRS80iiKVuxCslJe9a8SQs1Jgiq6cu2pLt2IOLd+cUO0t ETI8JWA8Jc+aZJ3XNev+hfWHPfpUdu4trO3pIUXTS2GS01+Ku9QZsR7Xllr6aj3G 8+NCP9ApA3k9szJFCM7d3cJ0WNlA4GZhVFSKmFMo56dZ8T0dRp8JJ2E5/XqTFlfi JU2pU/3OVhcXkPjSUPHqXF0ep4KaLxc4Ubc2SDk5BotqwlrDKTs= =/6UU -----END PGP SIGNATURE----- Merge tag 'python-pull-request' of https://gitlab.com/jsnow/qemu into staging Python patch roundup Mostly CI fixes and some small debugging improvements. # gpg: Signature made Wed 04 Jan 2023 21:04:26 GMT # gpg: using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full] # Primary key fingerprint: FAEB 9711 A12C F475 812F 18F2 88A9 064D 1835 61EB # Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76 CBD0 7DEF 8106 AAFC 390E * tag 'python-pull-request' of https://gitlab.com/jsnow/qemu: python: add 3.11 to supported list iotests/check: Fix typing for sys.exit() value Python: fix flake8 config python/machine: Handle termination cases without QMP python/machine: Add debug logging to key state changes Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
d1852caab1
|
@ -373,6 +373,7 @@ def _post_shutdown(self) -> None:
|
||||||
Called to cleanup the VM instance after the process has exited.
|
Called to cleanup the VM instance after the process has exited.
|
||||||
May also be called after a failed launch.
|
May also be called after a failed launch.
|
||||||
"""
|
"""
|
||||||
|
LOG.debug("Cleaning up after VM process")
|
||||||
try:
|
try:
|
||||||
self._close_qmp_connection()
|
self._close_qmp_connection()
|
||||||
except Exception as err: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
|
@ -497,6 +498,7 @@ def _early_cleanup(self) -> None:
|
||||||
# for QEMU to exit, while QEMU is waiting for the socket to
|
# for QEMU to exit, while QEMU is waiting for the socket to
|
||||||
# become writable.
|
# become writable.
|
||||||
if self._console_socket is not None:
|
if self._console_socket is not None:
|
||||||
|
LOG.debug("Closing console socket")
|
||||||
self._console_socket.close()
|
self._console_socket.close()
|
||||||
self._console_socket = None
|
self._console_socket = None
|
||||||
|
|
||||||
|
@ -507,6 +509,7 @@ def _hard_shutdown(self) -> None:
|
||||||
:raise subprocess.Timeout: When timeout is exceeds 60 seconds
|
:raise subprocess.Timeout: When timeout is exceeds 60 seconds
|
||||||
waiting for the QEMU process to terminate.
|
waiting for the QEMU process to terminate.
|
||||||
"""
|
"""
|
||||||
|
LOG.debug("Performing hard shutdown")
|
||||||
self._early_cleanup()
|
self._early_cleanup()
|
||||||
self._subp.kill()
|
self._subp.kill()
|
||||||
self._subp.wait(timeout=60)
|
self._subp.wait(timeout=60)
|
||||||
|
@ -523,8 +526,18 @@ def _soft_shutdown(self, timeout: Optional[int]) -> None:
|
||||||
:raise subprocess.TimeoutExpired: When timeout is exceeded waiting for
|
:raise subprocess.TimeoutExpired: When timeout is exceeded waiting for
|
||||||
the QEMU process to terminate.
|
the QEMU process to terminate.
|
||||||
"""
|
"""
|
||||||
|
LOG.debug("Attempting graceful termination")
|
||||||
|
|
||||||
self._early_cleanup()
|
self._early_cleanup()
|
||||||
|
|
||||||
|
if self._quit_issued:
|
||||||
|
LOG.debug(
|
||||||
|
"Anticipating QEMU termination due to prior 'quit' command, "
|
||||||
|
"or explicit call to wait()"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
LOG.debug("Politely asking QEMU to terminate")
|
||||||
|
|
||||||
if self._qmp_connection:
|
if self._qmp_connection:
|
||||||
try:
|
try:
|
||||||
if not self._quit_issued:
|
if not self._quit_issued:
|
||||||
|
@ -534,8 +547,18 @@ def _soft_shutdown(self, timeout: Optional[int]) -> None:
|
||||||
finally:
|
finally:
|
||||||
# Regardless, we want to quiesce the connection.
|
# Regardless, we want to quiesce the connection.
|
||||||
self._close_qmp_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
|
# May raise subprocess.TimeoutExpired
|
||||||
|
LOG.debug(
|
||||||
|
"Waiting (timeout=%s) for QEMU process (pid=%s) to terminate",
|
||||||
|
timeout, self._subp.pid
|
||||||
|
)
|
||||||
self._subp.wait(timeout=timeout)
|
self._subp.wait(timeout=timeout)
|
||||||
|
|
||||||
def _do_shutdown(self, timeout: Optional[int]) -> None:
|
def _do_shutdown(self, timeout: Optional[int]) -> None:
|
||||||
|
@ -553,6 +576,10 @@ def _do_shutdown(self, timeout: Optional[int]) -> None:
|
||||||
try:
|
try:
|
||||||
self._soft_shutdown(timeout)
|
self._soft_shutdown(timeout)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
if isinstance(exc, subprocess.TimeoutExpired):
|
||||||
|
LOG.debug("Timed out waiting for QEMU process to exit")
|
||||||
|
LOG.debug("Graceful shutdown failed", exc_info=True)
|
||||||
|
LOG.debug("Falling back to hard shutdown")
|
||||||
self._hard_shutdown()
|
self._hard_shutdown()
|
||||||
raise AbnormalShutdown("Could not perform graceful shutdown") \
|
raise AbnormalShutdown("Could not perform graceful shutdown") \
|
||||||
from exc
|
from exc
|
||||||
|
@ -575,6 +602,10 @@ def shutdown(self,
|
||||||
if not self._launched:
|
if not self._launched:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
LOG.debug("Shutting down VM appliance; timeout=%s", timeout)
|
||||||
|
if hard:
|
||||||
|
LOG.debug("Caller requests immediate termination of QEMU process.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if hard:
|
if hard:
|
||||||
self._user_killed = True
|
self._user_killed = True
|
||||||
|
|
|
@ -19,6 +19,7 @@ classifiers =
|
||||||
Programming Language :: Python :: 3.8
|
Programming Language :: Python :: 3.8
|
||||||
Programming Language :: Python :: 3.9
|
Programming Language :: Python :: 3.9
|
||||||
Programming Language :: Python :: 3.10
|
Programming Language :: Python :: 3.10
|
||||||
|
Programming Language :: Python :: 3.11
|
||||||
Typing :: Typed
|
Typing :: Typed
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
|
@ -71,7 +72,8 @@ console_scripts =
|
||||||
qmp-tui = qemu.qmp.qmp_tui:main [tui]
|
qmp-tui = qemu.qmp.qmp_tui:main [tui]
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
extend-ignore = E722 # Prefer pylint's bare-except checks to flake8's
|
# Prefer pylint's bare-except checks to flake8's
|
||||||
|
extend-ignore = E722
|
||||||
exclude = __pycache__,
|
exclude = __pycache__,
|
||||||
|
|
||||||
[mypy]
|
[mypy]
|
||||||
|
@ -158,7 +160,7 @@ multi_line_output=3
|
||||||
# of python available on your system to run this test.
|
# of python available on your system to run this test.
|
||||||
|
|
||||||
[tox:tox]
|
[tox:tox]
|
||||||
envlist = py36, py37, py38, py39, py310
|
envlist = py36, py37, py38, py39, py310, py311
|
||||||
skip_missing_interpreters = true
|
skip_missing_interpreters = true
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
|
|
|
@ -159,7 +159,7 @@ if __name__ == '__main__':
|
||||||
if not tests:
|
if not tests:
|
||||||
raise ValueError('No tests selected')
|
raise ValueError('No tests selected')
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
sys.exit(e)
|
sys.exit(str(e))
|
||||||
|
|
||||||
if args.dry_run:
|
if args.dry_run:
|
||||||
print('\n'.join(tests))
|
print('\n'.join(tests))
|
||||||
|
|
Loading…
Reference in a new issue