From patchwork Wed Jul 4 11:11:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 939247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41LJGp39CYz9s3q for ; Wed, 4 Jul 2018 21:12:01 +1000 (AEST) Received: from localhost ([::1]:46233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fafhX-0004w8-82 for incoming@patchwork.ozlabs.org; Wed, 04 Jul 2018 07:11:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fafh2-0004vJ-5H for qemu-devel@nongnu.org; Wed, 04 Jul 2018 07:11:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fafgy-0007G1-N3 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 07:11:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54702 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fafgy-0007FY-JZ for qemu-devel@nongnu.org; Wed, 04 Jul 2018 07:11:24 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47725407565B for ; Wed, 4 Jul 2018 11:11:23 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C4A7111C4A2; Wed, 4 Jul 2018 11:11:20 +0000 (UTC) From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Wed, 4 Jul 2018 12:11:18 +0100 Message-Id: <20180704111118.7241-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 04 Jul 2018 11:11:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 04 Jul 2018 11:11:23 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] chardev: unconditionally set FD_PASS feature for socket type=fd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é --- 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); }