[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/15] python/aqmp: add send_fd_scm
From: |
John Snow |
Subject: |
[PATCH 07/15] python/aqmp: add send_fd_scm |
Date: |
Fri, 17 Sep 2021 01:40:39 -0400 |
The single space is indeed required to successfully transmit the file
descriptor to QEMU.
Signed-off-by: John Snow <jsnow@redhat.com>
---
python/qemu/aqmp/qmp_client.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/aqmp/qmp_client.py
index d2ad7459f9..58f85990bc 100644
--- a/python/qemu/aqmp/qmp_client.py
+++ b/python/qemu/aqmp/qmp_client.py
@@ -9,6 +9,8 @@
import asyncio
import logging
+import socket
+import struct
from typing import (
Dict,
List,
@@ -624,3 +626,18 @@ async def execute(self, cmd: str,
"""
msg = self.make_execute_msg(cmd, arguments, oob=oob)
return await self.execute_msg(msg)
+
+ @upper_half
+ @require(Runstate.RUNNING)
+ def send_fd_scm(self, fd: int) -> None:
+ """
+ Send a file descriptor to the remote via SCM_RIGHTS.
+ """
+ assert self._writer is not None
+ sock = self._writer.transport.get_extra_info('socket')
+
+ # Python 3.9+ adds socket.send_fds(...)
+ sock.sendmsg(
+ [b' '],
+ [(socket.SOL_SOCKET, socket.SCM_RIGHTS, struct.pack('@i', fd))]
+ )
--
2.31.1
- Re: [PATCH 04/15] python/qmp: clear events on get_events() call, (continued)
- [PATCH 05/15] python/qmp: add send_fd_scm directly to QEMUMonitorProtocol, John Snow, 2021/09/17
- [PATCH 01/15] python/aqmp: add greeting property to QMPClient, John Snow, 2021/09/17
- [PATCH 03/15] python/aqmp: Return cleared events from EventListener.clear(), John Snow, 2021/09/17
- [PATCH 07/15] python/aqmp: add send_fd_scm,
John Snow <=
- [PATCH 06/15] python, iotests: remove socket_scm_helper, John Snow, 2021/09/17
- [PATCH 09/15] python/machine: remove has_quit argument, John Snow, 2021/09/17
- [PATCH 10/15] python/machine: Add support for AQMP backend, John Snow, 2021/09/17