diff options
author | Cleber Rosa <crosa@redhat.com> | 2019-10-28 19:04:04 -0400 |
---|---|---|
committer | Cleber Rosa <crosa@redhat.com> | 2019-10-28 19:04:04 -0400 |
commit | 085809670201c6d3a33e37dc753a23115ba8ceb3 (patch) | |
tree | ec874607c1a36196ad2d3f8317eacfcb3305fcf1 /python/qemu | |
parent | 5449d937cddf78a3c592e58228fd1c248edd0dad (diff) | |
download | qemu-085809670201c6d3a33e37dc753a23115ba8ceb3.zip qemu-085809670201c6d3a33e37dc753a23115ba8ceb3.tar.gz qemu-085809670201c6d3a33e37dc753a23115ba8ceb3.tar.bz2 |
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>
Diffstat (limited to 'python/qemu')
-rw-r--r-- | python/qemu/machine.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 2024e8b..a4631d6 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -277,10 +277,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 @@ -342,6 +338,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: |