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: <20190607034214.GB22416@habkost.net>
Reference: https://bugs.launchpad.net/qemu/+bug/1829779
From: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20190911023558.4880-2-crosa@redhat.com>
This commit is contained in:
Cleber Rosa 2019-10-28 19:04:04 -04:00
parent 5449d937cd
commit 0858096702
1 changed files with 7 additions and 4 deletions

View File

@ -277,10 +277,6 @@ def _post_shutdown(self):
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
@ -342,6 +338,13 @@ def shutdown(self, has_quit=False):
"""
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: