aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2021-11-18 15:46:20 -0500
committerJohn Snow <jsnow@redhat.com>2021-11-22 18:41:21 -0500
commita57cb3e23d5ac918a69d0aab918470ff0b429ff9 (patch)
treea4df7413b8026b6eaa3c0eaf981207f4df709a07 /python
parent206439cd8937a3dc556537074d5d37e5d74eb0d0 (diff)
downloadqemu-a57cb3e23d5ac918a69d0aab918470ff0b429ff9.zip
qemu-a57cb3e23d5ac918a69d0aab918470ff0b429ff9.tar.gz
qemu-a57cb3e23d5ac918a69d0aab918470ff0b429ff9.tar.bz2
python/aqmp: fix send_fd_scm for python 3.6.x
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>
Diffstat (limited to 'python')
-rw-r--r--python/qemu/aqmp/qmp_client.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/aqmp/qmp_client.py
index f987da0..8105e29 100644
--- a/python/qemu/aqmp/qmp_client.py
+++ b/python/qemu/aqmp/qmp_client.py
@@ -639,9 +639,12 @@ class QMPClient(AsyncProtocol[Message], Events):
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))]