[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/25] python/machine: close sock_pair in cleanup path
From: |
John Snow |
Subject: |
[PULL 02/25] python/machine: close sock_pair in cleanup path |
Date: |
Fri, 13 Oct 2023 15:09:17 -0400 |
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>
---
python/qemu/machine/machine.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index 345610d6e4..e26109e6f0 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -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()
--
2.41.0
- [PULL 00/25] Python patches, John Snow, 2023/10/13
- [PULL 08/25] python/qmp: remove Server.wait_closed() call for Python 3.12, John Snow, 2023/10/13
- [PULL 03/25] python/console_socket: accept existing FD in initializer, John Snow, 2023/10/13
- [PULL 02/25] python/machine: close sock_pair in cleanup path,
John Snow <=
- [PULL 04/25] python/machine: use socketpair() for console connections, John Snow, 2023/10/13
- [PULL 09/25] configure: fix error message to say Python 3.8, John Snow, 2023/10/13
- [PULL 11/25] python/qemu/qmp/legacy: cmd(): drop cmd_id unused argument, John Snow, 2023/10/13
- [PULL 05/25] python/machine: use socketpair() for qtest connection, John Snow, 2023/10/13
- [PULL 07/25] Python/iotests: Add type hint for nbd module, John Snow, 2023/10/13
- [PULL 06/25] python/machine: remove unused sock_dir argument, John Snow, 2023/10/13
- [PULL 10/25] Python: Enable python3.12 support, John Snow, 2023/10/13
- [PULL 01/25] python/machine: move socket setup out of _base_args property, John Snow, 2023/10/13
- [PULL 12/25] qmp_shell.py: _fill_completion() use .command() instead of .cmd(), John Snow, 2023/10/13
- [PULL 14/25] python: rename QEMUMonitorProtocol.cmd() to cmd_raw(), John Snow, 2023/10/13