[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 03/12] python/machine.py: Add _early_cleanup hook
From: |
John Snow |
Subject: |
[PATCH v5 03/12] python/machine.py: Add _early_cleanup hook |
Date: |
Fri, 10 Jul 2020 01:06:40 -0400 |
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: John Snow <jsnow@redhat.com>
---
python/qemu/machine.py | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 938c891b1d..4280aab380 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -354,16 +354,9 @@ def _launch(self):
close_fds=False)
self._post_launch()
- def wait(self):
+ def _early_cleanup(self) -> None:
"""
- Wait for the VM to power off
- """
- self._popen.wait()
- self._post_shutdown()
-
- def shutdown(self, has_quit=False, hard=False):
- """
- Terminate the VM and clean up
+ 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
@@ -372,6 +365,19 @@ def shutdown(self, has_quit=False, hard=False):
self._console_socket.close()
self._console_socket = None
+ def wait(self):
+ """
+ Wait for the VM to power off
+ """
+ self._popen.wait()
+ self._post_shutdown()
+
+ def shutdown(self, has_quit=False, hard=False):
+ """
+ Terminate the VM and clean up
+ """
+ self._early_cleanup()
+
if self.is_running():
if hard:
self._popen.kill()
--
2.21.3
- [PATCH v5 00/12] python/machine.py: refactor shutdown, John Snow, 2020/07/10
- [PATCH v5 02/12] python/machine.py: Close QMP socket in cleanup, John Snow, 2020/07/10
- [PATCH v5 01/12] python/machine.py: consolidate _post_shutdown(), John Snow, 2020/07/10
- [PATCH v5 03/12] python/machine.py: Add _early_cleanup hook,
John Snow <=
- [PATCH v5 05/12] python/machine.py: Prohibit multiple shutdown() calls, John Snow, 2020/07/10
- [PATCH v5 04/12] python/machine.py: Perform early cleanup for wait() calls, too, John Snow, 2020/07/10