Skip to content

Commit 0858096

Browse files
committed
Python libs: close console sockets before shutting down the VMs
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: <[email protected]> Reference: https://bugs.launchpad.net/qemu/+bug/1829779 From: Eduardo Habkost <[email protected]> Signed-off-by: Cleber Rosa <[email protected]> Message-Id: <[email protected]>
1 parent 5449d93 commit 0858096

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

python/qemu/machine.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,6 @@ def _post_shutdown(self):
277277

278278
self._qemu_log_path = None
279279

280-
if self._console_socket is not None:
281-
self._console_socket.close()
282-
self._console_socket = None
283-
284280
if self._temp_dir is not None:
285281
shutil.rmtree(self._temp_dir)
286282
self._temp_dir = None
@@ -342,6 +338,13 @@ def shutdown(self, has_quit=False):
342338
"""
343339
Terminate the VM and clean up
344340
"""
341+
# If we keep the console socket open, we may deadlock waiting
342+
# for QEMU to exit, while QEMU is waiting for the socket to
343+
# become writeable.
344+
if self._console_socket is not None:
345+
self._console_socket.close()
346+
self._console_socket = None
347+
345348
if self.is_running():
346349
try:
347350
if not has_quit:

0 commit comments

Comments
 (0)