[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen master] python/machine.py: Add _early_cleanup hook



commit e2c97f161294c702ee4a2dd08532d5df67f6bff4
Author:     John Snow <jsnow@xxxxxxxxxx>
AuthorDate: Fri Jul 10 01:06:40 2020 -0400
Commit:     Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
CommitDate: Tue Jul 14 22:22:22 2020 +0200

    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: John Snow <jsnow@xxxxxxxxxx>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
    Reviewed-by: Cleber Rosa <crosa@xxxxxxxxxx>
    Tested-by: Cleber Rosa <crosa@xxxxxxxxxx>
    Message-Id: <20200710050649.32434-4-jsnow@xxxxxxxxxx>
    Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
---
 python/qemu/machine.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index d3faa9a84c..127926b276 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -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:
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.