From nobody Sun Feb 8 10:50:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562861156; cv=none; d=zoho.com; s=zohoarc; b=WJX/y+BiaMKxCs7AqdfDazYZdzUGfBHG5mqXAwLDiN3zvwPSCOeatsMs+19S1QqosWh8gJ/OFmSGjkt3vC3jNEJ3azaQH25xLbtoyKioAFe4048YiiqvNiTv8X/cqlbHyuwvsRXbmhn/hFt2U3F3GtzzJDj6ks/1aWQEkobXjTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562861156; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/NhujkGNUvNumnoM1FaDVHj9KlookKV4ITGBpY4mS5g=; b=jUemHUhAKC6xuCzXPs1tS3DlqUJgBJTUDSEnSR7x6auuyOmeu8IkHi5vbsJVH2JM+nXmL38MZsibS51fcri48r+QaJwm2ih0/GWVlieJTpvvA8luXwmP24N2LT87104tVbM8jfq61KUO7uFklwYOc5ep5VS2SL8igSbKMvqt3Ew= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562861156985604.6669094994168; Thu, 11 Jul 2019 09:05:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6491681120; Thu, 11 Jul 2019 16:05:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30B3960603; Thu, 11 Jul 2019 16:05:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DE6E01833010; Thu, 11 Jul 2019 16:05:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6BG5gpO020569 for ; Thu, 11 Jul 2019 12:05:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 102885D973; Thu, 11 Jul 2019 16:05:42 +0000 (UTC) Received: from dhcp-17-95.lcy.redhat.com (unknown [10.42.17.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E9285D9CC; Thu, 11 Jul 2019 16:05:41 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 11 Jul 2019 17:05:11 +0100 Message-Id: <20190711160516.2130-25-berrange@redhat.com> In-Reply-To: <20190711160516.2130-1-berrange@redhat.com> References: <20190711160516.2130-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 24/29] remote: open secondary drivers via remote driver if needed X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 Jul 2019 16:05:55 +0000 (UTC) When the client has a connection to one of the hypervisor specific daemons (eg virtqemud), the app may still expect to use the secondary driver APIs (storage, network, etc). None of these will be registered in the hypervisor daemon, so we must explicitly open a connection to each of the daemons for the secondary drivers we need. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_daemon_dispatch.c | 82 ++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 13 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 856c5e48e7..c8a605c709 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1954,6 +1954,9 @@ remoteDispatchConnectOpen(virNetServerPtr server ATTR= IBUTE_UNUSED, unsigned int flags; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(= client); int rv =3D -1; +#ifndef LIBVIRTD + const char *type =3D NULL; +#endif =20 VIR_DEBUG("priv=3D%p conn=3D%p", priv, priv->conn); virMutexLock(&priv->lock); @@ -1972,20 +1975,73 @@ remoteDispatchConnectOpen(virNetServerPtr server AT= TRIBUTE_UNUSED, if (virNetServerClientGetReadonly(client)) flags |=3D VIR_CONNECT_RO; =20 - priv->conn =3D - flags & VIR_CONNECT_RO - ? virConnectOpenReadOnly(name) - : virConnectOpen(name); - - if (priv->conn =3D=3D NULL) - goto cleanup; +#define OPEN_DRIVER(var, uri) \ + do { \ + VIR_DEBUG("Opening driver %s", uri); \ + if (!(priv->var =3D flags & VIR_CONNECT_RO \ + ? virConnectOpenReadOnly(uri) \ + : virConnectOpen(uri))) \ + goto cleanup; \ + VIR_DEBUG("Opened %p", priv->var); \ + } while (0) =20 - priv->interfaceConn =3D virObjectRef(priv->conn); - priv->networkConn =3D virObjectRef(priv->conn); - priv->nodedevConn =3D virObjectRef(priv->conn); - priv->nwfilterConn =3D virObjectRef(priv->conn); - priv->secretConn =3D virObjectRef(priv->conn); - priv->storageConn =3D virObjectRef(priv->conn); + OPEN_DRIVER(conn, name); + +#ifndef LIBVIRTD + if (!(type =3D virConnectGetType(priv->conn))) + goto cleanup; + + VIR_DEBUG("Primary driver type is '%s'", type); + if (STREQ(type, "QEMU") || + STREQ(type, "LIBXL") || + STREQ(type, "LXC") || + STREQ(type, "VBOX") || + STREQ(type, "bhyve") || + STREQ(type, "vz") || + STREQ(type, "Parallels")) { + VIR_DEBUG("Hypervisor driver found, opening connections to seconda= ry drivers"); + OPEN_DRIVER(interfaceConn, getuid() =3D=3D 0 ? "interface:///syste= m" : "interface:///session"); + OPEN_DRIVER(networkConn, getuid() =3D=3D 0 ? "network:///system" := "network:///session"); + OPEN_DRIVER(nodedevConn, getuid() =3D=3D 0 ? "nodedev:///system" := "nodedev:///session"); + if (getuid() =3D=3D 0) + OPEN_DRIVER(nwfilterConn, "nwfilter:///system"); + OPEN_DRIVER(secretConn, getuid() =3D=3D 0 ? "secret:///system" : "= secret:///session"); + OPEN_DRIVER(storageConn, getuid() =3D=3D 0 ? "storage:///system" := "storage:///session"); + } else if (STREQ(type, "interface")) { + VIR_DEBUG("Interface driver found"); + priv->interfaceConn =3D virObjectRef(priv->conn); + } else if (STREQ(type, "network")) { + VIR_DEBUG("Network driver found"); + priv->networkConn =3D virObjectRef(priv->conn); + } else if (STREQ(type, "nodedev")) { + VIR_DEBUG("Nodedev driver found"); + priv->nodedevConn =3D virObjectRef(priv->conn); + } else if (STREQ(type, "nwfilter")) { + VIR_DEBUG("NWFilter driver found"); + priv->nwfilterConn =3D virObjectRef(priv->conn); + } else if (STREQ(type, "secret")) { + VIR_DEBUG("Secret driver found"); + priv->secretConn =3D virObjectRef(priv->conn); + } else if (STREQ(type, "storage")) { + VIR_DEBUG("Storage driver found"); + priv->storageConn =3D virObjectRef(priv->conn); + + /* Co-open the secret driver, as apps using the storage driver may= well + * need access to secrets for storage auth + */ + OPEN_DRIVER(secretConn, getuid =3D=3D 0 ? "secret:///system" : "se= cret:///session"); + } else { +#endif /* LIBVIRTD */ + VIR_DEBUG("Pointing secondary drivers to primary"); + priv->interfaceConn =3D virObjectRef(priv->conn); + priv->networkConn =3D virObjectRef(priv->conn); + priv->nodedevConn =3D virObjectRef(priv->conn); + priv->nwfilterConn =3D virObjectRef(priv->conn); + priv->secretConn =3D virObjectRef(priv->conn); + priv->storageConn =3D virObjectRef(priv->conn); +#ifndef LIBVIRTD + } +#endif /* LIBVIRTD */ =20 /* force update the @readonly attribute which was inherited from the * virNetServerService object - this is important for sockets that are= RW --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list