]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
python/machine.py: Add _early_cleanup hook
authorJohn Snow <jsnow@redhat.com>
Fri, 10 Jul 2020 05:06:40 +0000 (01:06 -0400)
committerPhilippe Mathieu-Daudé <philmd@redhat.com>
Tue, 14 Jul 2020 20:22:22 +0000 (22:22 +0200)
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>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20200710050649.32434-4-jsnow@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
python/qemu/machine.py

index d3faa9a84cebf7e882ede940969ea0cb7f7bd011..127926b2760fbb85a1efc1ad453b9a8d4dd3c628 100644 (file)
@@ -365,6 +365,17 @@ class QEMUMachine:
                                        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 @@ class QEMUMachine:
         """
         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: