From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH] chardev: unconditionally set FD_PASS feature for socket type=fd
Date: Wed, 4 Jul 2018 12:11:18 +0100 [thread overview]
Message-ID: <20180704111118.7241-1-berrange@redhat.com> (raw)
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.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
chardev/char-socket.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 17519ec589..b495d6a851 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -990,8 +990,18 @@ static void qmp_chardev_open_socket(Chardev *chr,
s->addr = addr = socket_address_flatten(sock->addr);
qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE);
- /* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */
- if (addr->type == SOCKET_ADDRESS_TYPE_UNIX) {
+ /*
+ * We can't tell at this point if the "fd" we're passed is
+ * a UNIX socket or not, so can't reliably set the
+ * FD_PASS feature. vhost-user, however, checks for this
+ * feature early before we've even created the I/O channel,
+ * so we can't wait until later to set the feature. Thus
+ * we optimistically set the FD_PASS feature. If the passed
+ * in "fd" is not a UNIX socket, there will be an error
+ * reported later anyway.
+ */
+ if (addr->type == SOCKET_ADDRESS_TYPE_UNIX ||
+ addr->type == SOCKET_ADDRESS_TYPE_FD) {
qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS);
}
--
2.17.1
next reply other threads:[~2018-07-04 11:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 11:11 Daniel P. Berrangé [this message]
2018-07-04 11:53 ` [Qemu-devel] [PATCH] chardev: unconditionally set FD_PASS feature for socket type=fd Paolo Bonzini
2018-07-04 12:08 ` Daniel P. Berrangé
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=20180704111118.7241-1-berrange@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).