From nobody Wed May 14 11:37:56 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522250326958860.0878550161151; Wed, 28 Mar 2018 08:18:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC72751453; Wed, 28 Mar 2018 15:18:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 826115D6A8; Wed, 28 Mar 2018 15:18:45 +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 4C10B4CA97; Wed, 28 Mar 2018 15:18:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2SFIdYM014180 for ; Wed, 28 Mar 2018 11:18:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C79B94581; Wed, 28 Mar 2018 15:18:39 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CE1B6353C; Wed, 28 Mar 2018 15:18:38 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 28 Mar 2018 16:18:27 +0100 Message-Id: <20180328151832.7683-3-berrange@redhat.com> In-Reply-To: <20180328151832.7683-1-berrange@redhat.com> References: <20180328151832.7683-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/7] remote: use a separate connection for interface APIs 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 28 Mar 2018 15:18:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/remote/remote_daemon.h | 1 + src/remote/remote_daemon_dispatch.c | 4 ++++ src/rpc/gendispatch.pl | 25 ++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h index 4467f71da9..31f433c15d 100644 --- a/src/remote/remote_daemon.h +++ b/src/remote/remote_daemon.h @@ -74,6 +74,7 @@ struct daemonClientPrivate { * called, it will be set back to NULL if that succeeds. */ virConnectPtr conn; + virConnectPtr interfaceConn; =20 daemonClientStreamPtr streams; }; diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 121d114ae3..7971646c28 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1740,6 +1740,8 @@ void remoteClientFree(void *data) =20 if (priv->conn) virConnectClose(priv->conn); + if (priv->interfaceConn) + virConnectClose(priv->interfaceConn); =20 VIR_FREE(priv); } @@ -1814,6 +1816,8 @@ remoteDispatchConnectOpen(virNetServerPtr server ATTR= IBUTE_UNUSED, if (priv->conn =3D=3D NULL) goto cleanup; =20 + priv->interfaceConn =3D virObjectRef(priv->conn); + /* force update the @readonly attribute which was inherited from the * virNetServerService object - this is important for sockets that are= RW * by default, but do accept RO flags, e.g. TCP diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index e11921f3d9..23b17c0815 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -111,9 +111,32 @@ sub name_to_TypeName { } =20 sub get_conn_arg { + my $proc =3D shift; + my $args =3D shift; + my $rets =3D shift; + if ($structprefix eq "admin") { return "priv->dmn"; } + + my @types; + push @types, @{$args} if $args; + push @types, @{$rets} if $rets; + + # This correctly detects most APIs + foreach my $type (@types) { + if ($type =3D~ /remote_nonnull_interface/) { + return "priv->interfaceConn"; + } + } + + # This is for the few virConnect APIs that + # return things which aren't objects. eg list + # of pool names, or number of pools. + if ($proc =3D~ /Connect.*Interface/ || $proc =3D~ /InterfaceChange/) { + return "priv->interfaceConn"; + } + return "priv->conn"; } =20 @@ -481,7 +504,7 @@ elsif ($mode eq "server") { my @free_list =3D (); my @free_list_on_error =3D ("virNetMessageSaveError(rerr);"); =20 - my $conn =3D get_conn_arg(); + my $conn =3D get_conn_arg($call->{ProcName}, $call->{args_members}= , $call->{ret_members}); =20 # handle arguments to the function if ($argtype ne "void") { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list