qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] chardev: unconditionally set FD_PASS feature for socket type=fd
Date: Wed, 4 Jul 2018 13:08:26 +0100	[thread overview]
Message-ID: <20180704120826.GD32267@redhat.com> (raw)
In-Reply-To: <f56b799f-7f30-391f-c2d8-15f95524758c@redhat.com>

On Wed, Jul 04, 2018 at 01:53:03PM +0200, Paolo Bonzini wrote:
> On 04/07/2018 13:11, Daniel P. Berrangé wrote:
> > The vhostuser network backend requires the chardev it is using to have
> > the FD passing feature. It checks this upfront when initializing the
> > network backend and reports an error if not set.
> > 
> > The socket chardev has to set the FD_PASS feature during early
> > initialization to satisfy the vhostuser backend, and at this point
> > the socket has not been initialized. It is thus unable to do a live
> > check on the socket to see if it supports FD passing (aka is a UNIX
> > socket). As a result it has to blindly set FD_PASS feature based
> > solely on info in the SocketAddress struct, such as address type.
> > 
> > Unfortunately libvirt wishes to use FD passing to provide the UNIX
> > domain socket listener, and as a result the FD_PASS feature is no
> > longer set, which breaks vhostuser's checks, despite the fact that
> > FD passing will in fact work later.
> > 
> > This unconditionally sets FD_PASS feature for any socket address
> > which has type==fd. Thus will be wrong if the passed in FD was not
> > a UNIX socket, but if an attempt is later made to use FD passing
> > we'll still get an error reported by the QIOChannelSocket class.
> > So the effective of setting the chardev FD_PASS feature early
> > is merely to delay error reporting.
> 
> Could you query with getsockopt or getsockname in tcp_chr_connect?

That potentially executes asynchronously in the backend and vhostuser
checks it when it first resolves the chardev ID. IOW the point where
vhostuser checks, all we have is the SocketAddress struct - in some
case we might be lucky & have connected, but we can't assume it :-(

Previously vhostuser poked directly in the QemuOpts for the chardev
which I changed to this feature based approach in

  commit 0a73336d96397c80881219d080518fac6f1ecacb
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Fri Oct 7 13:18:34 2016 +0100

    net: don't poke at chardev internal QemuOpts

This whole mess is merely so that vhostuser can print out an error
message if you point it to a chardev that isn't a UNIX socket. If
anything I'm half inclined to just delete that upfront error check
entirely. 

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 :|

  reply	other threads:[~2018-07-04 12:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 11:11 [Qemu-devel] [PATCH] chardev: unconditionally set FD_PASS feature for socket type=fd Daniel P. Berrangé
2018-07-04 11:53 ` Paolo Bonzini
2018-07-04 12:08   ` Daniel P. Berrangé [this message]
2018-07-16 16:57     ` Marc-André Lureau
2018-07-16 17:03       ` Daniel P. Berrangé
2018-07-16 18:22         ` Marc-André Lureau

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=20180704120826.GD32267@redhat.com \
    --to=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).