Skip to content

Commit

Permalink
python/machine: close sock_pair in cleanup path
Browse files Browse the repository at this point in the history
If everything has gone smoothly, we'll already have closed the socket we
gave to the child during post_launch. The other half of the pair that we
gave to the QMP connection should, likewise, be definitively closed by
now.

However, in the cleanup path, it's possible we've created the socketpair
but flubbed the launch and need to clean up resources. These resources
*would* be handled by the garbage collector, but that can happen at
unpredictable times. Nicer to just clean them up synchronously on the
exit path, here.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20230928044943.849073-3-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
  • Loading branch information
jnsnow committed Oct 11, 2023
1 parent 91e11db commit 612b3ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/qemu/machine/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ def _post_shutdown(self) -> None:
finally:
assert self._qmp_connection is None

if self._sock_pair:
self._sock_pair[0].close()
self._sock_pair[1].close()
self._sock_pair = None

self._close_qemu_log_file()

self._load_io_log()
Expand Down

0 comments on commit 612b3ba

Please sign in to comment.