[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 7/7] python/aqmp: fix send_fd_scm for python 3.6.x
From: |
John Snow |
Subject: |
[PULL 7/7] python/aqmp: fix send_fd_scm for python 3.6.x |
Date: |
Mon, 22 Nov 2021 21:38:05 -0500 |
3.6 doesn't play keepaway with the socket object, so we don't need to go
fishing for it on this version. In fact, so long as 'sendmsg' is still
available, it's probably preferable to just use that method and only go
fishing for forbidden details when we absolutely have to.
Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Message-id: 20211118204620.1897674-8-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
---
python/qemu/aqmp/qmp_client.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/aqmp/qmp_client.py
index f987da02eb..8105e29fa8 100644
--- a/python/qemu/aqmp/qmp_client.py
+++ b/python/qemu/aqmp/qmp_client.py
@@ -639,9 +639,12 @@ def send_fd_scm(self, fd: int) -> None:
if sock.family != socket.AF_UNIX:
raise AQMPError("Sending file descriptors requires a UNIX socket.")
- # Void the warranty sticker.
- # Access to sendmsg in asyncio is scheduled for removal in Python 3.11.
- sock = sock._sock # pylint: disable=protected-access
+ if not hasattr(sock, 'sendmsg'):
+ # We need to void the warranty sticker.
+ # Access to sendmsg is scheduled for removal in Python 3.11.
+ # Find the real backing socket to use it anyway.
+ sock = sock._sock # pylint: disable=protected-access
+
sock.sendmsg(
[b' '],
[(socket.SOL_SOCKET, socket.SCM_RIGHTS, struct.pack('@i', fd))]
--
2.31.1
- [PULL 0/7] Python patches, John Snow, 2021/11/22
- [PULL 1/7] python/machine: add @sock_dir property, John Snow, 2021/11/22
- [PULL 2/7] python/machine: remove _remove_monitor_sockfile property, John Snow, 2021/11/22
- [PULL 3/7] python/machine: add instance disambiguator to default nickname, John Snow, 2021/11/22
- [PULL 5/7] python/machine: handle "fast" QEMU terminations, John Snow, 2021/11/22
- [PULL 4/7] python/machine: move more variable initializations to _pre_launch, John Snow, 2021/11/22
- [PULL 6/7] scripts/device-crash-test: Use a QMP timeout, John Snow, 2021/11/22
- [PULL 7/7] python/aqmp: fix send_fd_scm for python 3.6.x,
John Snow <=
- Re: [PULL 0/7] Python patches, Richard Henderson, 2021/11/23