qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 05/15] python/qmp: add send_fd_scm directly to QEMUMonitorPro


From: Hanna Reitz
Subject: Re: [PATCH 05/15] python/qmp: add send_fd_scm directly to QEMUMonitorProtocol
Date: Fri, 17 Sep 2021 15:21:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 17.09.21 07:40, John Snow wrote:
It turns out you can do this directly from Python ... and because of
this, you don't need to worry about setting the inheritability of the
fds or spawning another process.

Doing this is helpful because it allows QEMUMonitorProtocol to keep its
file descriptor and socket object as private implementation details.

*that* is helpful in turn because it allows me to write a compatible,
  alternative implementation.

Bit of a weird indentation here.

Signed-off-by: John Snow <jsnow@redhat.com>
---
  python/qemu/machine/machine.py | 44 +++++++---------------------------
  python/qemu/qmp/__init__.py    | 21 +++++++---------
  2 files changed, 18 insertions(+), 47 deletions(-)

diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index ae945ca3c9..1c6532a3d6 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -213,48 +213,22 @@ def add_fd(self: _T, fd: int, fdset: int,
      def send_fd_scm(self, fd: Optional[int] = None,
                      file_path: Optional[str] = None) -> int:

[...]

          if file_path is not None:
              assert fd is None
-            fd_param.append(file_path)
+            with open(file_path, "rb") as passfile:
+                fd = passfile.fileno()
+                self._qmp.send_fd_scm(fd)

Seems a bit strange to send an fd that is then immediately closed, but that’s what socket_scm_helper did, and so it looks like the fd is effectively duplicated.  OK then.

Reviewed-by: Hanna Reitz <hreitz@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]