On Tue, Jan 03, 2023 at 03:08:12PM +0400, marcandre.lur...@redhat.com wrote: > From: Marc-André Lureau <marcandre.lur...@redhat.com> > > A process with enough capabilities can duplicate a socket to QEMU. Add a > QMP command to import it and add it to the monitor fd list, so it can be > later used by other commands. > > Note that we actually store the SOCKET in the FD list, appropriate care > must now be taken to use the correct socket functions (similar approach > is taken by our io/ code and in glib, this is internal and shouldn't > affect the QEMU/QMP users) > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > qapi/misc.json | 32 ++++++++++++++++++++++ > monitor/misc.c | 74 ++++++++++++++++++++++++++++++++++++++++---------- > 2 files changed, 91 insertions(+), 15 deletions(-) > > diff --git a/qapi/misc.json b/qapi/misc.json > index 27ef5a2b20..a19dd78fab 100644 > --- a/qapi/misc.json > +++ b/qapi/misc.json > @@ -272,6 +272,38 @@ > ## > { 'command': 'getfd', 'data': {'fdname': 'str'} } > > +## > +# @get-win32-socket: > +# > +# Add a socket that was duplicated to QEMU process with WSADuplicateSocketW() > +# via WSASocket() & WSAPROTOCOL_INFOW structure and assign it a name. A > SOCKET > +# is considered as a kind of "file descriptor" by QMP clients, for historical > +# reasons and simplicity, although QEMU takes care to use socket functions > +# appropriately. > +# > +# @info: the WSAPROTOCOL_INFOW structure (encoded in base64) > +# > +# @fdname: file descriptor name > +# > +# Returns: Nothing on success > +# > +# Since: 8.0 > +# > +# Notes: If @fdname already exists, the file descriptor assigned to > +# it will be closed and replaced by the received file > +# descriptor. > +# > +# The 'closefd' command can be used to explicitly close the > +# file descriptor when it is no longer needed. > +# > +# Example: > +# > +# -> { "execute": "get-win32-socket", "arguments": { "info": "abcd123..", > fdname": "skclient" } } > +# <- { "return": {} } > +# > +## > +{ 'command': 'get-win32-socket', 'data': {'info': 'str', 'fdname': 'str'}, > 'if': 'CONFIG_WIN32' }
IIUC, this is needed because 'getfd' doesn't work on Windows ? Can't we just implement getfd on Windows, using this WSAPROTOCOL_INFOW structure passing, or are you anticipating that future Windows make get normal 'getfd' support ? With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|