[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32 |
Date: |
Tue, 7 Feb 2023 14:54:29 +0000 |
User-agent: |
Mutt/2.2.9 (2022-11-12) |
On Tue, Feb 07, 2023 at 06:25:33PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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 <marcandre.lureau@redhat.com>
> ---
> 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.
> #
> # @fdname: file descriptor name
> #
> +# @wsa-info: a WSAPROTOCOL_INFOW structure (encoded in base64). Since 8.0.
This is a clever trick, but it also feels pretty gross from
POV of QMP design normal practice, which would be to define
a struct in QAPI to represent the WSAPROTOCOL_INFOW contents.
The main downside would be that its more verbose to convert
between the windows and QAPI structs.
> @@ -270,7 +278,11 @@
> # <- { "return": {} }
> #
> ##
> -{ 'command': 'getfd', 'data': {'fdname': 'str'} }
> +{ 'command': 'getfd', 'data': {
> + 'fdname': 'str',
> + '*wsa-info': {'type': 'str', 'if': 'CONFIG_WIN32'}
> + }
> +}
snip
> +void qmp_getfd(const char *fdname,
> +#ifdef WIN32
> + const char *wsa_info,
> +#endif
> + Error **errp)
> +{
> + Monitor *cur_mon = monitor_cur();
> + int fd;
> +
> +#ifdef WIN32
> + if (wsa_info) {
> + g_autofree WSAPROTOCOL_INFOW *info = NULL;
> + gsize len;
> + SOCKET sk;
> +
> + info = (void *)g_base64_decode(wsa_info, &len);
> + if (len != sizeof(*info)) {
> + error_setg(errp, "Invalid WSAPROTOCOL_INFOW value");
> + return;
> + }
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 :|
- Re: [PATCH v3 07/10] qapi: implement conditional command arguments, (continued)
- Re: [PATCH v3 07/10] qapi: implement conditional command arguments, Markus Armbruster, 2023/02/17
- Re: [PATCH v3 07/10] qapi: implement conditional command arguments, Marc-André Lureau, 2023/02/18
- Re: [PATCH v3 07/10] qapi: implement conditional command arguments, Markus Armbruster, 2023/02/20
- Re: [PATCH v3 07/10] qapi: implement conditional command arguments, Marc-André Lureau, 2023/02/22
- Re: [PATCH v3 07/10] qapi: implement conditional command arguments, Markus Armbruster, 2023/02/22
- Re: [PATCH v3 07/10] qapi: implement conditional command arguments, Marc-André Lureau, 2023/02/22
- Re: [PATCH v3 07/10] qapi: implement conditional command arguments, Marc-André Lureau, 2023/02/27
[PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32, marcandre . lureau, 2023/02/07
- Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32, Philippe Mathieu-Daudé, 2023/02/07
- Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32,
Daniel P . Berrangé <=
- Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32, Markus Armbruster, 2023/02/17
- Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32, Marc-André Lureau, 2023/02/18
- Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32, Markus Armbruster, 2023/02/20
- Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32, Daniel P . Berrangé, 2023/02/20
- Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32, Marc-André Lureau, 2023/02/20
- Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32, Markus Armbruster, 2023/02/20
[PATCH v3 10/10] qtest: enable vnc-display test on win32, marcandre . lureau, 2023/02/07
[PATCH v3 09/10] libqtest: make qtest_qmp_add_client work on win32, marcandre . lureau, 2023/02/07