On Fri, Sep 17, 2021 at 9:21 AM Hanna Reitz wrote: > 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 > > --- > > 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. > > Same boat. It's weird, but it seems to work, and it's how the old interface (ultimately) behaved, so ... https://i.imgur.com/O0CQXoh.png > Reviewed-by: Hanna Reitz > >