Skip to content
Snippets Groups Projects
Commit e2c97f16 authored by John Snow's avatar John Snow Committed by Philippe Mathieu-Daudé
Browse files

python/machine.py: Add _early_cleanup hook


Some parts of cleanup need to occur prior to shutdown, otherwise
shutdown might break. Move this into a suitably named method/callback.

Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: default avatarCleber Rosa <crosa@redhat.com>
Tested-by: default avatarCleber Rosa <crosa@redhat.com>
Message-Id: <20200710050649.32434-4-jsnow@redhat.com>
Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
parent 671940e6
No related branches found
No related tags found
No related merge requests found
......@@ -365,6 +365,17 @@ def _launch(self):
close_fds=False)
self._post_launch()
def _early_cleanup(self) -> None:
"""
Perform any cleanup that needs to happen before the VM exits.
"""
# If we keep the console socket open, we may deadlock waiting
# for QEMU to exit, while QEMU is waiting for the socket to
# become writeable.
if self._console_socket is not None:
self._console_socket.close()
self._console_socket = None
def wait(self):
"""
Wait for the VM to power off
......@@ -376,12 +387,7 @@ def shutdown(self, has_quit=False, hard=False):
"""
Terminate the VM and clean up
"""
# If we keep the console socket open, we may deadlock waiting
# for QEMU to exit, while QEMU is waiting for the socket to
# become writeable.
if self._console_socket is not None:
self._console_socket.close()
self._console_socket = None
self._early_cleanup()
if self.is_running():
if hard:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment