All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: qemu-devel@nongnu.org, "Beraldo Leal" <bleal@redhat.com>,
	"Eric Blake" <eblake@redhat.com>, "Stefan Weil" <sw@weilnetz.de>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>
Subject: Re: [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32
Date: Mon, 20 Feb 2023 11:50:34 +0100	[thread overview]
Message-ID: <87wn4cd30l.fsf@pond.sub.org> (raw)
In-Reply-To: <CAJ+F1CKUmnQ36vCdE07R6rF3H=Kgd684uay=sJXbP9ttEraUxg@mail.gmail.com> ("Marc-André Lureau"'s message of "Mon, 20 Feb 2023 13:52:00 +0400")

Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> Hi
>
> On Mon, Feb 20, 2023 at 12:26 PM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> Marc-André Lureau <marcandre.lureau@gmail.com> writes:
>>
>> > Hi Markus
>> >
>> > On Fri, Feb 17, 2023 at 1:49 PM Markus Armbruster <armbru@redhat.com> wrote:
>> >>
>> >> marcandre.lureau@redhat.com writes:
>> >>
>> >> > 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.
>> >>
>> >> 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...
>> >
>> > We don't have to, after all we don't explain how to use sendmsg/cmsg
>> > stuff to pass FDs.
>> >
>> > I will drop the part about "A SOCKET is considered as a kind of "file
>> > descriptor" in QMP context", after we get "[PATCH 0/4] win32: do not
>> > mix SOCKET and fd space"
>> > (https://patchew.org/QEMU/20230212204942.1905959-1-marcandre.lureau@redhat.com/)
>> > merged.
>>
>> Would it make sense to rebase this series on top of that one, so we
>> can have simpler documentation from the start?
>
> Sure, if only I had more reviews/acks...

I'll try to have a look.

>> >> What does this command do under Windows before this patch?  Fail always?
>> >
>> > Without ancillary data support on Windows, you can't make it work.
>>
>> Yes, but how does it fail?  Hmm, you actually answer that below.

[...]

>> >> >  # 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?
>> >
>> > It attempts to get the fd from the last recv, but it will fail on
>> > Windows, this is not available.
>>
>> So it fails exactly like it fails on a POSIX host when you execute getfd
>> without passing along a file descriptor with SCM_RIGHTS.  Correct?
>
> Correct, I get something like:
> Error { class: GenericError, desc: "No file descriptor supplied via
> SCM_RIGHTS", id: None }

Works for me, thanks!



  reply	other threads:[~2023-02-20 10:51 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 14:25 [PATCH v3 00/10] Teach 'getfd' QMP command to import win32 sockets marcandre.lureau
2023-02-07 14:25 ` [PATCH v3 01/10] tests: fix path separator, use g_build_filename() marcandre.lureau
2023-02-07 14:25 ` [PATCH v3 02/10] char: do not double-close fd when failing to add client marcandre.lureau
2023-02-07 14:43   ` Thomas Huth
2023-02-07 14:25 ` [PATCH v3 03/10] tests/docker: fix a win32 error due to portability marcandre.lureau
2023-02-27 12:11   ` Alex Bennée
2023-02-07 14:25 ` [PATCH v3 04/10] osdep: implement qemu_socketpair() for win32 marcandre.lureau
2023-02-07 14:25 ` [PATCH v3 05/10] qmp: 'add_client' actually expects sockets marcandre.lureau
2023-02-14 13:25   ` Markus Armbruster
2023-02-07 14:25 ` [PATCH v3 06/10] monitor: release the lock before calling close() marcandre.lureau
2023-02-07 14:52   ` Philippe Mathieu-Daudé
2023-02-14 13:33   ` Markus Armbruster
2023-02-14 13:36     ` Marc-André Lureau
2023-02-14 13:49       ` Daniel P. Berrangé
2023-02-14 16:23         ` Markus Armbruster
2023-02-14 16:55           ` Peter Xu
2023-02-28 18:51         ` Dr. David Alan Gilbert
2023-03-02  9:34   ` Alex Bennée
2023-03-06 15:29     ` Markus Armbruster
2023-03-06 15:35     ` Markus Armbruster
2023-02-07 14:25 ` [PATCH v3 07/10] qapi: implement conditional command arguments marcandre.lureau
2023-02-09 12:41   ` Markus Armbruster
2023-02-12 20:59     ` Marc-André Lureau
2023-02-17  8:28   ` Markus Armbruster
2023-02-18 10:45     ` Marc-André Lureau
2023-02-20  8:09       ` Markus Armbruster
2023-02-22  8:05         ` Marc-André Lureau
2023-02-22 10:23           ` Markus Armbruster
2023-02-22 10:29             ` Marc-André Lureau
2023-02-27 11:22               ` Marc-André Lureau
2023-02-28 15:58             ` Eric Blake
2023-03-01  9:24               ` Daniel P. Berrangé
2023-03-01 13:16                 ` Markus Armbruster
2023-03-01 13:21                   ` Marc-André Lureau
2023-03-02  6:58                     ` Markus Armbruster
2023-03-02  9:31                       ` Daniel P. Berrangé
2023-03-02 11:09                         ` Markus Armbruster
2023-03-02 13:30                           ` Markus Armbruster
2023-02-28 15:54   ` Eric Blake
2023-02-28 19:16     ` Marc-André Lureau
2023-02-07 14:25 ` [PATCH v3 08/10] qmp: teach 'getfd' to import sockets on win32 marcandre.lureau
2023-02-07 14:50   ` Philippe Mathieu-Daudé
2023-02-07 14:54   ` Daniel P. Berrangé
2023-02-08  7:28     ` Marc-André Lureau
2023-02-17  9:48   ` Markus Armbruster
2023-02-18 10:15     ` Marc-André Lureau
2023-02-20  8:26       ` Markus Armbruster
2023-02-20  9:30         ` Daniel P. Berrangé
2023-02-20  9:52         ` Marc-André Lureau
2023-02-20 10:50           ` Markus Armbruster [this message]
2023-02-07 14:25 ` [PATCH v3 09/10] libqtest: make qtest_qmp_add_client work " marcandre.lureau
2023-02-07 14:50   ` Philippe Mathieu-Daudé
2023-02-07 14:25 ` [PATCH v3 10/10] qtest: enable vnc-display test " marcandre.lureau
2023-02-07 14:37   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wn4cd30l.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=bleal@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.