diff mbox series

[v5,03/12] python/machine.py: Add _early_cleanup hook

Message ID 20200710050649.32434-4-jsnow@redhat.com
State New
Headers show
Series None | expand

Commit Message

John Snow July 10, 2020, 5:06 a.m. UTC
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 mbox series

Patch

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()