qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 1/2] Python libs: close console sockets before shutt


From: Cleber Rosa
Subject: [Qemu-devel] [PATCH 1/2] Python libs: close console sockets before shutting down the VMs
Date: Tue, 10 Sep 2019 22:35:57 -0400

Currently, the console socket on QEMUMachine is closed after the QMP
command to gracefully exit QEMU is executed.  Because of a possible
deadlock (QEMU waiting for the socket to become writable) let's close
the console socket earlier.

Reference: <address@hidden>
Reference: https://bugs.launchpad.net/qemu/+bug/1829779
From: Eduardo Habkost <address@hidden>
Signed-off-by: Cleber Rosa <address@hidden>
---
 python/qemu/machine.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 128a3d1dc2..4f533b7881 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -271,10 +271,6 @@ class QEMUMachine(object):
 
         self._qemu_log_path = None
 
-        if self._console_socket is not None:
-            self._console_socket.close()
-            self._console_socket = None
-
         if self._temp_dir is not None:
             shutil.rmtree(self._temp_dir)
             self._temp_dir = None
@@ -333,6 +329,13 @@ class QEMUMachine(object):
         """
         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
+
         if self.is_running():
             try:
                 if not has_quit:
-- 
2.21.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]