[email protected] writes:
> From: Marc-André Lureau <[email protected]>
>
> A process with enough capabilities can duplicate a socket to QEMU.
> Modify 'getfd' 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 <[email protected]>
> ---
> qapi/misc.json | 16 ++++++++--
> monitor/fds.c | 79 ++++++++++++++++++++++++++++++++++++----------
> monitor/hmp-cmds.c | 6 +++-
> 3 files changed, 81 insertions(+), 20 deletions(-)
>
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 27ef5a2b20..cd36d8befb 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -249,10 +249,18 @@
> ##
> # @getfd:
> #
> -# Receive a file descriptor via SCM rights and assign it a name
> +# On UNIX, receive a file descriptor via SCM rights and assign it a name.
> +#
> +# On Windows, (where ancillary socket fd-passing isn't an option yet), 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" in QMP context, for historical
> +# reasons and simplicity. QEMU takes care to use socket functions
> appropriately.
The Windows part explains things in terms of the C socket API. Less
than ideal for the QEMU QMP Reference Manual, isn't it? I don't know
nearly enough about this stuff to suggest concrete improvements...
What does this command do under Windows before this patch? Fail always?
Wrap your lines a bit earlier, please.
> #
> # @fdname: file descriptor name
> #
> +# @wsa-info: a WSAPROTOCOL_INFOW structure (encoded in base64). Since 8.0.
> +#
No way around passing a binary blob?
> # Returns: Nothing on success
> #
> # Since: 0.14
> @@ -270,7 +278,11 @@
> # <- { "return": {} }
> #
> ##
> -{ 'command': 'getfd', 'data': {'fdname': 'str'} }
> +{ 'command': 'getfd', 'data': {
> + 'fdname': 'str',
> + '*wsa-info': {'type': 'str', 'if': 'CONFIG_WIN32'}
> + }
> +}
What happens when QEMU runs on a Windows host and the client doesn't
pass @wsa-info?
>
> ##
> # @closefd: