From nobody Sun Feb 8 12:37:39 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=1563897936; cv=none; d=zoho.com; s=zohoarc; b=mZH5X4RzJVWayoe4hWxifTAAVWsphr+LNpMTeDO55WKtl1D8FN6an0pO681Y6NhcqcL7zlhJB8+yuJ79GkEQQFXCvOcKdE5BOyDPoiXmstjcPYKgjoEZ45dzyepa8iZP6xGc+ljiooYw6nmBdOxpESeDgmG352NgjcrR/SKXYA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563897936; 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=3UjtDPTha/JC8l2o2ex6lFABSsWHBqUYsconOhHN0Rg=; b=mvJqokdTh9Ht1H6eF7GwLJ58lqiq4Wz8g3sJi8DP0snWy4tFYDK1OnNVjsOtF+N/opN9qJ2pkbnBDzuUrKM+ZVJvawWNUV0HFX+6GB8T8xZ4Bacwxy9hbiz6WEmHa2NzDYIDXYeVLh8r416xqG8rpjeuKvZSfGvxwP9UKRtgiMk= 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 1563897936823999.9395893206306; Tue, 23 Jul 2019 09:05:36 -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 6868CA3EA7; Tue, 23 Jul 2019 16:05:35 +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 3C4135B685; Tue, 23 Jul 2019 16:05:35 +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 EF15D18045D2; Tue, 23 Jul 2019 16:05:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6NG5SxR025312 for ; Tue, 23 Jul 2019 12:05:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id D8B875C22D; Tue, 23 Jul 2019 16:05:28 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.112.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04E295C8A4; Tue, 23 Jul 2019 16:05:26 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 23 Jul 2019 17:03:13 +0100 Message-Id: <20190723160319.18153-36-berrange@redhat.com> In-Reply-To: <20190723160319.18153-1-berrange@redhat.com> References: <20190723160319.18153-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 35/41] remote: change hand written methods to not directly access connection 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.30]); Tue, 23 Jul 2019 16:05:36 +0000 (UTC) The driver dispatch methods access the priv->conn variables directly. In future we want to dynamically open the connections for the secondary driver. Thus we want the methods to call a method to get the connection handle instead of assuming the private variable is non-NULL. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_daemon_dispatch.c | 782 ++++++++++------------------ 1 file changed, 289 insertions(+), 493 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index ecce0b0112..b677bd44ee 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -2147,15 +2147,12 @@ remoteDispatchDomainGetSchedulerType(virNetServerPt= r server ATTRIBUTE_UNUSED, char *type; int nparams; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (!(type =3D virDomainGetSchedulerType(dom, &nparams))) @@ -2184,13 +2181,10 @@ remoteDispatchDomainGetSchedulerParameters(virNetSe= rverPtr server ATTRIBUTE_UNUS virTypedParameterPtr params =3D NULL; int nparams =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); @@ -2200,7 +2194,7 @@ remoteDispatchDomainGetSchedulerParameters(virNetServ= erPtr server ATTRIBUTE_UNUS goto cleanup; nparams =3D args->nparams; =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0) @@ -2234,13 +2228,10 @@ remoteDispatchDomainGetSchedulerParametersFlags(vir= NetServerPtr server ATTRIBUTE virTypedParameterPtr params =3D NULL; int nparams =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); @@ -2250,7 +2241,7 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNe= tServerPtr server ATTRIBUTE goto cleanup; nparams =3D args->nparams; =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetSchedulerParametersFlags(dom, params, &nparams, @@ -2286,13 +2277,10 @@ remoteDispatchDomainMemoryStats(virNetServerPtr ser= ver ATTRIBUTE_UNUSED, int nr_stats; size_t i; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2300,7 +2288,7 @@ remoteDispatchDomainMemoryStats(virNetServerPtr serve= r ATTRIBUTE_UNUSED, goto cleanup; } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 /* Allocate stats array for making dispatch call */ @@ -2345,15 +2333,12 @@ remoteDispatchDomainBlockPeek(virNetServerPtr serve= r ATTRIBUTE_UNUSED, size_t size; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; path =3D args->path; offset =3D args->offset; @@ -2399,15 +2384,12 @@ remoteDispatchDomainBlockStatsFlags(virNetServerPtr= server ATTRIBUTE_UNUSED, int nparams =3D 0; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; flags =3D args->flags; =20 @@ -2461,15 +2443,12 @@ remoteDispatchDomainMemoryPeek(virNetServerPtr serv= er ATTRIBUTE_UNUSED, size_t size; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; offset =3D args->offset; size =3D args->size; @@ -2511,15 +2490,12 @@ remoteDispatchDomainGetSecurityLabel(virNetServerPt= r server ATTRIBUTE_UNUSED, virDomainPtr dom =3D NULL; virSecurityLabelPtr seclabel =3D NULL; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (VIR_ALLOC(seclabel) < 0) @@ -2556,15 +2532,12 @@ remoteDispatchDomainGetSecurityLabelList(virNetServ= erPtr server ATTRIBUTE_UNUSED virSecurityLabelPtr seclabels =3D NULL; int len, rv =3D -1; size_t i; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if ((len =3D virDomainGetSecurityLabelList(dom, &seclabels)) < 0) { @@ -2610,16 +2583,13 @@ remoteDispatchNodeGetSecurityModel(virNetServerPtr = server ATTRIBUTE_UNUSED, { virSecurityModel secmodel; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 memset(&secmodel, 0, sizeof(secmodel)); - if (virNodeGetSecurityModel(priv->conn, &secmodel) < 0) + if (virNodeGetSecurityModel(conn, &secmodel) < 0) goto cleanup; =20 ret->model.model_len =3D strlen(secmodel.model) + 1; @@ -2652,15 +2622,12 @@ remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr = server ATTRIBUTE_UNUSED, unsigned char *cpumaps =3D NULL; int num; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (args->ncpumaps > REMOTE_VCPUINFO_MAX) { @@ -2714,15 +2681,12 @@ remoteDispatchDomainPinEmulator(virNetServerPtr ser= ver ATTRIBUTE_UNUSED, { int rv =3D -1; virDomainPtr dom =3D NULL; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainPinEmulator(dom, @@ -2753,15 +2717,12 @@ remoteDispatchDomainGetEmulatorPinInfo(virNetServer= Ptr server ATTRIBUTE_UNUSED, unsigned char *cpumaps =3D NULL; int r; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 /* Allocate buffers to take the results */ @@ -2804,15 +2765,12 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server= ATTRIBUTE_UNUSED, int info_len; size_t i; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (args->maxinfo > REMOTE_VCPUINFO_MAX) { @@ -2881,18 +2839,16 @@ remoteDispatchDomainGetIOThreadInfo(virNetServerPtr= server ATTRIBUTE_UNUSED, { int rv =3D -1; size_t i; - struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(= client); virDomainIOThreadInfoPtr *info =3D NULL; virDomainPtr dom =3D NULL; remote_domain_iothread_info *dst; int ninfo =3D 0; + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if ((ninfo =3D virDomainGetIOThreadInfo(dom, &info, args->flags)) < 0) @@ -2957,13 +2913,10 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr = server ATTRIBUTE_UNUSED, char **uri_out; char *dname; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 uri_in =3D args->uri_in =3D=3D NULL ? NULL : *args->uri_in; dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; @@ -2972,7 +2925,7 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr se= rver ATTRIBUTE_UNUSED, if (VIR_ALLOC(uri_out) < 0) goto cleanup; =20 - if (virDomainMigratePrepare(priv->conn, &cookie, &cookielen, + if (virDomainMigratePrepare(conn, &cookie, &cookielen, uri_in, uri_out, args->flags, dname, args->resource) < 0) goto cleanup; @@ -3012,13 +2965,10 @@ remoteDispatchDomainMigratePrepare2(virNetServerPtr= server ATTRIBUTE_UNUSED, char **uri_out; char *dname; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 uri_in =3D args->uri_in =3D=3D NULL ? NULL : *args->uri_in; dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; @@ -3027,7 +2977,7 @@ remoteDispatchDomainMigratePrepare2(virNetServerPtr s= erver ATTRIBUTE_UNUSED, if (VIR_ALLOC(uri_out) < 0) goto cleanup; =20 - if (virDomainMigratePrepare2(priv->conn, &cookie, &cookielen, + if (virDomainMigratePrepare2(conn, &cookie, &cookielen, uri_in, uri_out, args->flags, dname, args->resource, args->dom_xml) < 0) @@ -3063,13 +3013,10 @@ remoteDispatchDomainGetMemoryParameters(virNetServe= rPtr server ATTRIBUTE_UNUSED, int nparams =3D 0; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 flags =3D args->flags; =20 @@ -3081,7 +3028,7 @@ remoteDispatchDomainGetMemoryParameters(virNetServerP= tr server ATTRIBUTE_UNUSED, goto cleanup; nparams =3D args->nparams; =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0) @@ -3125,13 +3072,10 @@ remoteDispatchDomainGetNumaParameters(virNetServerP= tr server ATTRIBUTE_UNUSED, int nparams =3D 0; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 flags =3D args->flags; =20 @@ -3143,7 +3087,7 @@ remoteDispatchDomainGetNumaParameters(virNetServerPtr= server ATTRIBUTE_UNUSED, goto cleanup; nparams =3D args->nparams; =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetNumaParameters(dom, params, &nparams, flags) < 0) @@ -3187,13 +3131,10 @@ remoteDispatchDomainGetBlkioParameters(virNetServer= Ptr server ATTRIBUTE_UNUSED, int nparams =3D 0; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 flags =3D args->flags; =20 @@ -3205,7 +3146,7 @@ remoteDispatchDomainGetBlkioParameters(virNetServerPt= r server ATTRIBUTE_UNUSED, goto cleanup; nparams =3D args->nparams; =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0) @@ -3250,13 +3191,10 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr serve= r ATTRIBUTE_UNUSED, int nparams =3D 0; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 flags =3D args->flags; =20 @@ -3268,7 +3206,7 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server = ATTRIBUTE_UNUSED, goto cleanup; nparams =3D args->nparams; =20 - if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, flags) < = 0) + if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, flags) < 0) goto cleanup; =20 /* In this case, we need to send back the number of stats @@ -3322,13 +3260,10 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr se= rver ATTRIBUTE_UNUSED, int nparams =3D 0; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 flags =3D args->flags; =20 @@ -3340,7 +3275,7 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr serv= er ATTRIBUTE_UNUSED, goto cleanup; nparams =3D args->nparams; =20 - if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, flags= ) < 0) + if (virNodeGetMemoryStats(conn, cellNum, params, &nparams, flags) < 0) goto cleanup; =20 /* In this case, we need to send back the number of parameters @@ -3392,15 +3327,12 @@ remoteDispatchDomainGetLaunchSecurityInfo(virNetSer= verPtr server ATTRIBUTE_UNUSE virTypedParameterPtr params =3D NULL; int nparams =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetLaunchSecurityInfo(dom, ¶ms, &nparams, args->flags= ) < 0) @@ -3439,15 +3371,12 @@ remoteDispatchDomainGetPerfEvents(virNetServerPtr s= erver ATTRIBUTE_UNUSED, virTypedParameterPtr params =3D NULL; int nparams =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetPerfEvents(dom, ¶ms, &nparams, args->flags) < 0) @@ -3485,15 +3414,12 @@ remoteDispatchDomainGetBlockJobInfo(virNetServerPtr= server ATTRIBUTE_UNUSED, virDomainPtr dom =3D NULL; virDomainBlockJobInfo tmp; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 rv =3D virDomainGetBlockJobInfo(dom, args->path, &tmp, args->flags); @@ -3526,13 +3452,10 @@ remoteDispatchDomainGetBlockIoTune(virNetServerPtr = server ATTRIBUTE_UNUSED, int rv =3D -1; virTypedParameterPtr params =3D NULL; int nparams =3D 0; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->nparams > REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); @@ -3543,7 +3466,7 @@ remoteDispatchDomainGetBlockIoTune(virNetServerPtr se= rver ATTRIBUTE_UNUSED, goto cleanup; nparams =3D args->nparams; =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetBlockIoTune(dom, args->disk ? *args->disk : NULL, @@ -4103,15 +4026,12 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr s= erver ATTRIBUTE_UNUSED, virNodeDevicePtr dev =3D NULL; const char *parent =3D NULL; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetNodeDevConn(client); =20 - if (!priv->nodedevConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dev =3D virNodeDeviceLookupByName(priv->nodedevConn, args->name)= )) + if (!(dev =3D virNodeDeviceLookupByName(conn, args->name))) goto cleanup; =20 parent =3D virNodeDeviceGetParent(dev); @@ -4143,15 +4063,14 @@ remoteDispatchConnectRegisterCloseCallback(virNetSe= rverPtr server ATTRIBUTE_UNUS int rv =3D -1; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (virConnectRegisterCloseCallback(priv->conn, + if (virConnectRegisterCloseCallback(conn, remoteRelayConnectionClosedEvent, client, NULL) < 0) goto cleanup; @@ -4175,15 +4094,14 @@ remoteDispatchConnectUnregisterCloseCallback(virNet= ServerPtr server ATTRIBUTE_UN int rv =3D -1; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (virConnectUnregisterCloseCallback(priv->conn, + if (virConnectUnregisterCloseCallback(conn, remoteRelayConnectionClosedEvent= ) < 0) goto cleanup; =20 @@ -4210,14 +4128,13 @@ remoteDispatchConnectDomainEventRegister(virNetServ= erPtr server ATTRIBUTE_UNUSED daemonClientEventCallbackPtr ref; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + /* If we call register first, we could append a complete callback * to our array, but on OOM append failure, we'd have to then hope * deregister works to undo our register. So instead we append an @@ -4238,7 +4155,7 @@ remoteDispatchConnectDomainEventRegister(virNetServer= Ptr server ATTRIBUTE_UNUSED callback) < 0) goto cleanup; =20 - if ((callbackID =3D virConnectDomainEventRegisterAny(priv->conn, + if ((callbackID =3D virConnectDomainEventRegisterAny(conn, NULL, VIR_DOMAIN_EVENT_ID= _LIFECYCLE, VIR_DOMAIN_EVENT_CA= LLBACK(remoteRelayDomainEventLifecycle), @@ -4274,14 +4191,13 @@ remoteDispatchConnectDomainEventDeregister(virNetSe= rverPtr server ATTRIBUTE_UNUS size_t i; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + for (i =3D 0; i < priv->ndomainEventCallbacks; i++) { if (priv->domainEventCallbacks[i]->eventID =3D=3D VIR_DOMAIN_EVENT= _ID_LIFECYCLE) { callbackID =3D priv->domainEventCallbacks[i]->callbackID; @@ -4296,7 +4212,7 @@ remoteDispatchConnectDomainEventDeregister(virNetServ= erPtr server ATTRIBUTE_UNUS goto cleanup; } =20 - if (virConnectDomainEventDeregisterAny(priv->conn, callbackID) < 0) + if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0) goto cleanup; =20 VIR_DELETE_ELEMENT(priv->domainEventCallbacks, i, @@ -4360,15 +4276,12 @@ remoteDispatchSecretGetValue(virNetServerPtr server= ATTRIBUTE_UNUSED, size_t value_size; unsigned char *value; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetSecretConn(client); =20 - if (!priv->secretConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(secret =3D get_nonnull_secret(priv->secretConn, args->secret))) + if (!(secret =3D get_nonnull_secret(conn, args->secret))) goto cleanup; =20 if (!(value =3D virSecretGetValue(secret, &value_size, args->flags))) @@ -4396,15 +4309,12 @@ remoteDispatchDomainGetState(virNetServerPtr server= ATTRIBUTE_UNUSED, { virDomainPtr dom =3D NULL; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetState(dom, &ret->state, &ret->reason, args->flags) < 0) @@ -4438,14 +4348,13 @@ remoteDispatchConnectDomainEventRegisterAny(virNetS= erverPtr server ATTRIBUTE_UNU daemonClientEventCallbackPtr ref; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + /* We intentionally do not use VIR_DOMAIN_EVENT_ID_LAST here; any * new domain events added after this point should only use the * modern callback style of RPC. */ @@ -4474,7 +4383,7 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSer= verPtr server ATTRIBUTE_UNU callback) < 0) goto cleanup; =20 - if ((callbackID =3D virConnectDomainEventRegisterAny(priv->conn, + if ((callbackID =3D virConnectDomainEventRegisterAny(conn, NULL, args->eventID, domainEventCallback= s[args->eventID], @@ -4514,16 +4423,15 @@ remoteDispatchConnectDomainEventCallbackRegisterAny= (virNetServerPtr server ATTRI struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virDomainPtr dom =3D NULL; - - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + if (args->dom && - !(dom =3D get_nonnull_domain(priv->conn, *args->dom))) + !(dom =3D get_nonnull_domain(conn, *args->dom))) goto cleanup; =20 if (args->eventID >=3D VIR_DOMAIN_EVENT_ID_LAST || args->eventID < 0) { @@ -4549,7 +4457,7 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(v= irNetServerPtr server ATTRI callback) < 0) goto cleanup; =20 - if ((callbackID =3D virConnectDomainEventRegisterAny(priv->conn, + if ((callbackID =3D virConnectDomainEventRegisterAny(conn, dom, args->eventID, domainEventCallback= s[args->eventID], @@ -4588,14 +4496,13 @@ remoteDispatchConnectDomainEventDeregisterAny(virNe= tServerPtr server ATTRIBUTE_U size_t i; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + /* We intentionally do not use VIR_DOMAIN_EVENT_ID_LAST here; any * new domain events added after this point should only use the * modern callback style of RPC. */ @@ -4618,7 +4525,7 @@ remoteDispatchConnectDomainEventDeregisterAny(virNetS= erverPtr server ATTRIBUTE_U goto cleanup; } =20 - if (virConnectDomainEventDeregisterAny(priv->conn, callbackID) < 0) + if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0) goto cleanup; =20 VIR_DELETE_ELEMENT(priv->domainEventCallbacks, i, @@ -4645,14 +4552,13 @@ remoteDispatchConnectDomainEventCallbackDeregisterA= ny(virNetServerPtr server ATT size_t i; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + for (i =3D 0; i < priv->ndomainEventCallbacks; i++) { if (priv->domainEventCallbacks[i]->callbackID =3D=3D args->callbac= kID) break; @@ -4664,7 +4570,7 @@ remoteDispatchConnectDomainEventCallbackDeregisterAny= (virNetServerPtr server ATT goto cleanup; } =20 - if (virConnectDomainEventDeregisterAny(priv->conn, args->callbackID) <= 0) + if (virConnectDomainEventDeregisterAny(conn, args->callbackID) < 0) goto cleanup; =20 VIR_DELETE_ELEMENT(priv->domainEventCallbacks, i, @@ -4690,15 +4596,12 @@ qemuDispatchDomainMonitorCommand(virNetServerPtr se= rver ATTRIBUTE_UNUSED, { virDomainPtr dom =3D NULL; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainQemuMonitorCommand(dom, args->cmd, &ret->result, @@ -4730,15 +4633,12 @@ remoteDispatchDomainMigrateBegin3(virNetServerPtr s= erver ATTRIBUTE_UNUSED, char *cookieout =3D NULL; int cookieoutlen =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 xmlin =3D args->xmlin =3D=3D NULL ? NULL : *args->xmlin; @@ -4780,13 +4680,10 @@ remoteDispatchDomainMigratePrepare3(virNetServerPtr= server ATTRIBUTE_UNUSED, char **uri_out; char *dname; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 uri_in =3D args->uri_in =3D=3D NULL ? NULL : *args->uri_in; dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; @@ -4795,7 +4692,7 @@ remoteDispatchDomainMigratePrepare3(virNetServerPtr s= erver ATTRIBUTE_UNUSED, if (VIR_ALLOC(uri_out) < 0) goto cleanup; =20 - if (virDomainMigratePrepare3(priv->conn, + if (virDomainMigratePrepare3(conn, args->cookie_in.cookie_in_val, args->cookie_in.cookie_in_len, &cookieout, &cookieoutlen, @@ -4838,15 +4735,12 @@ remoteDispatchDomainMigratePerform3(virNetServerPtr= server ATTRIBUTE_UNUSED, char *cookieout =3D NULL; int cookieoutlen =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 xmlin =3D args->xmlin =3D=3D NULL ? NULL : *args->xmlin; @@ -4891,18 +4785,15 @@ remoteDispatchDomainMigrateFinish3(virNetServerPtr = server ATTRIBUTE_UNUSED, char *uri; char *dconnuri; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 uri =3D args->uri =3D=3D NULL ? NULL : *args->uri; dconnuri =3D args->dconnuri =3D=3D NULL ? NULL : *args->dconnuri; =20 - if (!(dom =3D virDomainMigrateFinish3(priv->conn, args->dname, + if (!(dom =3D virDomainMigrateFinish3(conn, args->dname, args->cookie_in.cookie_in_val, args->cookie_in.cookie_in_len, &cookieout, &cookieoutlen, @@ -4940,15 +4831,12 @@ remoteDispatchDomainMigrateConfirm3(virNetServerPtr= server ATTRIBUTE_UNUSED, { virDomainPtr dom =3D NULL; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainMigrateConfirm3(dom, @@ -4976,8 +4864,7 @@ static int remoteDispatchConnectSupportsFeature(virNe= tServerPtr server ATTRIBUTE { int rv =3D -1; int supported =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D NULL; =20 /* This feature is checked before opening the connection, thus we must * check it first. @@ -4989,10 +4876,10 @@ static int remoteDispatchConnectSupportsFeature(vir= NetServerPtr server ATTRIBUTE goto done; } =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + conn =3D remoteGetHypervisorConn(client); + + if (!conn) goto cleanup; - } =20 switch ((virDrvFeature) args->feature) { case VIR_DRV_FEATURE_FD_PASSING: @@ -5012,7 +4899,7 @@ static int remoteDispatchConnectSupportsFeature(virNe= tServerPtr server ATTRIBUTE case VIR_DRV_FEATURE_MIGRATION_OFFLINE: case VIR_DRV_FEATURE_MIGRATION_PARAMS: default: - if ((supported =3D virConnectSupportsFeature(priv->conn, args->fea= ture)) < 0) + if ((supported =3D virConnectSupportsFeature(conn, args->feature))= < 0) goto cleanup; break; case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE: @@ -5041,15 +4928,12 @@ remoteDispatchDomainOpenGraphics(virNetServerPtr se= rver ATTRIBUTE_UNUSED, virDomainPtr dom =3D NULL; int rv =3D -1; int fd =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if ((fd =3D virNetMessageDupFD(msg, 0)) < 0) @@ -5082,15 +4966,12 @@ remoteDispatchDomainOpenGraphicsFd(virNetServerPtr = server ATTRIBUTE_UNUSED, virDomainPtr dom =3D NULL; int rv =3D -1; int fd =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if ((fd =3D virDomainOpenGraphicsFD(dom, @@ -5129,13 +5010,10 @@ remoteDispatchDomainGetInterfaceParameters(virNetSe= rverPtr server ATTRIBUTE_UNUS int nparams =3D 0; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 flags =3D args->flags; =20 @@ -5147,7 +5025,7 @@ remoteDispatchDomainGetInterfaceParameters(virNetServ= erPtr server ATTRIBUTE_UNUS goto cleanup; nparams =3D args->nparams; =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetInterfaceParameters(dom, device, params, &nparams, fla= gs) < 0) @@ -5187,16 +5065,13 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr ser= ver ATTRIBUTE_UNUSED, remote_domain_get_cpu_stats_ret *ret) { virDomainPtr dom =3D NULL; - struct daemonClientPrivate *priv; virTypedParameterPtr params =3D NULL; int rv =3D -1; int percpu_len =3D 0; + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - priv =3D virNetServerClientGetPrivateData(client); - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->nparams > REMOTE_NODE_CPU_STATS_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); @@ -5211,7 +5086,7 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr serve= r ATTRIBUTE_UNUSED, VIR_ALLOC_N(params, args->ncpus * args->nparams) < 0) goto cleanup; =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 percpu_len =3D virDomainGetCPUStats(dom, params, args->nparams, @@ -5261,15 +5136,12 @@ remoteDispatchDomainGetDiskErrors(virNetServerPtr s= erver ATTRIBUTE_UNUSED, virDomainPtr dom =3D NULL; virDomainDiskErrorPtr errors =3D NULL; int len =3D 0; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (args->maxerrors > REMOTE_DOMAIN_DISK_ERRORS_MAX) { @@ -5321,15 +5193,12 @@ remoteDispatchNodeGetSevInfo(virNetServerPtr server= ATTRIBUTE_UNUSED, virTypedParameterPtr params =3D NULL; int nparams =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (virNodeGetSEVInfo(priv->conn, ¶ms, &nparams, args->flags) < 0) + if (virNodeGetSEVInfo(conn, ¶ms, &nparams, args->flags) < 0) goto cleanup; =20 if (nparams > REMOTE_NODE_SEV_INFO_MAX) { @@ -5366,13 +5235,10 @@ remoteDispatchNodeGetMemoryParameters(virNetServerP= tr server ATTRIBUTE_UNUSED, int nparams =3D 0; unsigned int flags; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 flags =3D args->flags; =20 @@ -5384,7 +5250,7 @@ remoteDispatchNodeGetMemoryParameters(virNetServerPtr= server ATTRIBUTE_UNUSED, goto cleanup; nparams =3D args->nparams; =20 - if (virNodeGetMemoryParameters(priv->conn, params, &nparams, flags) < = 0) + if (virNodeGetMemoryParameters(conn, params, &nparams, flags) < 0) goto cleanup; =20 /* In this case, we need to send back the number of parameters @@ -5424,17 +5290,14 @@ remoteDispatchNodeGetCPUMap(virNetServerPtr server = ATTRIBUTE_UNUSED, unsigned int flags; int cpunum; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 flags =3D args->flags; =20 - cpunum =3D virNodeGetCPUMap(priv->conn, args->need_map ? &cpumap : NUL= L, + cpunum =3D virNodeGetCPUMap(conn, args->need_map ? &cpumap : NULL, args->need_online ? &online : NULL, flags); if (cpunum < 0) goto cleanup; @@ -5466,19 +5329,16 @@ lxcDispatchDomainOpenNamespace(virNetServerPtr serv= er ATTRIBUTE_UNUSED, lxc_domain_open_namespace_args *args) { int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); int *fdlist =3D NULL; int ret; virDomainPtr dom =3D NULL; size_t i; + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 ret =3D virDomainLxcOpenNamespace(dom, @@ -5520,15 +5380,12 @@ remoteDispatchDomainGetJobStats(virNetServerPtr ser= ver ATTRIBUTE_UNUSED, virTypedParameterPtr params =3D NULL; int nparams =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetJobStats(dom, &ret->type, ¶ms, @@ -5573,13 +5430,10 @@ remoteDispatchDomainMigrateBegin3Params(virNetServe= rPtr server ATTRIBUTE_UNUSED, char *cookieout =3D NULL; int cookieoutlen =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) { virReportError(VIR_ERR_RPC, @@ -5588,7 +5442,7 @@ remoteDispatchDomainMigrateBegin3Params(virNetServerP= tr server ATTRIBUTE_UNUSED, goto cleanup; } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virTypedParamsDeserialize((virTypedParameterRemotePtr) args->param= s.params_val, @@ -5629,13 +5483,10 @@ remoteDispatchDomainMigratePrepare3Params(virNetSer= verPtr server ATTRIBUTE_UNUSE int cookieoutlen =3D 0; char **uri_out; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) { virReportError(VIR_ERR_RPC, @@ -5653,7 +5504,7 @@ remoteDispatchDomainMigratePrepare3Params(virNetServe= rPtr server ATTRIBUTE_UNUSE if (VIR_ALLOC(uri_out) < 0) goto cleanup; =20 - if (virDomainMigratePrepare3Params(priv->conn, params, nparams, + if (virDomainMigratePrepare3Params(conn, params, nparams, args->cookie_in.cookie_in_val, args->cookie_in.cookie_in_len, &cookieout, &cookieoutlen, @@ -5688,15 +5539,12 @@ remoteDispatchDomainMigratePrepareTunnel3Params(vir= NetServerPtr server ATTRIBUTE char *cookieout =3D NULL; int cookieoutlen =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); virStreamPtr st =3D NULL; daemonClientStreamPtr stream =3D NULL; + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) { virReportError(VIR_ERR_RPC, @@ -5710,12 +5558,12 @@ remoteDispatchDomainMigratePrepareTunnel3Params(vir= NetServerPtr server ATTRIBUTE 0, ¶ms, &nparams) < 0) goto cleanup; =20 - if (!(st =3D virStreamNew(priv->conn, VIR_STREAM_NONBLOCK)) || + if (!(st =3D virStreamNew(conn, VIR_STREAM_NONBLOCK)) || !(stream =3D daemonCreateClientStream(client, st, remoteProgram, &msg->header, false))) goto cleanup; =20 - if (virDomainMigratePrepareTunnel3Params(priv->conn, st, params, npara= ms, + if (virDomainMigratePrepareTunnel3Params(conn, st, params, nparams, args->cookie_in.cookie_in_val, args->cookie_in.cookie_in_len, &cookieout, &cookieoutlen, @@ -5760,13 +5608,10 @@ remoteDispatchDomainMigratePerform3Params(virNetSer= verPtr server ATTRIBUTE_UNUSE int cookieoutlen =3D 0; char *dconnuri; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) { virReportError(VIR_ERR_RPC, @@ -5775,7 +5620,7 @@ remoteDispatchDomainMigratePerform3Params(virNetServe= rPtr server ATTRIBUTE_UNUSE goto cleanup; } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virTypedParamsDeserialize((virTypedParameterRemotePtr) args->param= s.params_val, @@ -5820,13 +5665,10 @@ remoteDispatchDomainMigrateFinish3Params(virNetServ= erPtr server ATTRIBUTE_UNUSED char *cookieout =3D NULL; int cookieoutlen =3D 0; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) { virReportError(VIR_ERR_RPC, @@ -5840,7 +5682,7 @@ remoteDispatchDomainMigrateFinish3Params(virNetServer= Ptr server ATTRIBUTE_UNUSED 0, ¶ms, &nparams) < 0) goto cleanup; =20 - dom =3D virDomainMigrateFinish3Params(priv->conn, params, nparams, + dom =3D virDomainMigrateFinish3Params(conn, params, nparams, args->cookie_in.cookie_in_val, args->cookie_in.cookie_in_len, &cookieout, &cookieoutlen, @@ -5878,13 +5720,10 @@ remoteDispatchDomainMigrateConfirm3Params(virNetSer= verPtr server ATTRIBUTE_UNUSE int nparams =3D 0; virDomainPtr dom =3D NULL; int rv =3D -1; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) { virReportError(VIR_ERR_RPC, @@ -5893,7 +5732,7 @@ remoteDispatchDomainMigrateConfirm3Params(virNetServe= rPtr server ATTRIBUTE_UNUSE goto cleanup; } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virTypedParamsDeserialize((virTypedParameterRemotePtr) args->param= s.params_val, @@ -5928,15 +5767,12 @@ remoteDispatchConnectGetCPUModelNames(virNetServerP= tr server ATTRIBUTE_UNUSED, { int len, rv =3D -1; char **models =3D NULL; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - len =3D virConnectGetCPUModelNames(priv->conn, args->arch, + len =3D virConnectGetCPUModelNames(conn, args->arch, args->need_results ? &models : NULL, args->flags); if (len < 0) @@ -5980,16 +5816,13 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServer= Ptr server ATTRIBUTE_UNUSED, { int rv =3D -1; virDomainPtr dom =3D NULL; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); int *files =3D NULL; unsigned int nfiles =3D 0; size_t i; + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (VIR_ALLOC_N(files, msg->nfds) < 0) goto cleanup; @@ -5999,7 +5832,7 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServerPt= r server ATTRIBUTE_UNUSED, nfiles++; } =20 - if ((dom =3D virDomainCreateXMLWithFiles(priv->conn, args->xml_desc, + if ((dom =3D virDomainCreateXMLWithFiles(conn, args->xml_desc, nfiles, files, args->flags)) =3D=3D NULL) goto cleanup; @@ -6029,16 +5862,13 @@ static int remoteDispatchDomainCreateWithFiles(virN= etServerPtr server ATTRIBUTE_ { int rv =3D -1; virDomainPtr dom =3D NULL; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); int *files =3D NULL; unsigned int nfiles =3D 0; size_t i; + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (VIR_ALLOC_N(files, msg->nfds) < 0) goto cleanup; @@ -6048,7 +5878,7 @@ static int remoteDispatchDomainCreateWithFiles(virNet= ServerPtr server ATTRIBUTE_ nfiles++; } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainCreateWithFiles(dom, @@ -6084,19 +5914,18 @@ remoteDispatchConnectNetworkEventRegisterAny(virNet= ServerPtr server ATTRIBUTE_UN int rv =3D -1; daemonClientEventCallbackPtr callback =3D NULL; daemonClientEventCallbackPtr ref; + virNetworkPtr net =3D NULL; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - virNetworkPtr net =3D NULL; - - if (!priv->networkConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetNetworkConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + if (args->net && - !(net =3D get_nonnull_network(priv->networkConn, *args->net))) + !(net =3D get_nonnull_network(conn, *args->net))) goto cleanup; =20 if (args->eventID >=3D VIR_NETWORK_EVENT_ID_LAST || args->eventID < 0)= { @@ -6122,7 +5951,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetSe= rverPtr server ATTRIBUTE_UN callback) < 0) goto cleanup; =20 - if ((callbackID =3D virConnectNetworkEventRegisterAny(priv->networkCon= n, + if ((callbackID =3D virConnectNetworkEventRegisterAny(conn, net, args->eventID, networkEventCallba= cks[args->eventID], @@ -6160,14 +5989,13 @@ remoteDispatchConnectNetworkEventDeregisterAny(virN= etServerPtr server ATTRIBUTE_ size_t i; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->networkConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetNetworkConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + for (i =3D 0; i < priv->nnetworkEventCallbacks; i++) { if (priv->networkEventCallbacks[i]->callbackID =3D=3D args->callba= ckID) break; @@ -6179,7 +6007,7 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNet= ServerPtr server ATTRIBUTE_ goto cleanup; } =20 - if (virConnectNetworkEventDeregisterAny(priv->networkConn, args->callb= ackID) < 0) + if (virConnectNetworkEventDeregisterAny(conn, args->callbackID) < 0) goto cleanup; =20 VIR_DELETE_ELEMENT(priv->networkEventCallbacks, i, @@ -6209,16 +6037,15 @@ remoteDispatchConnectStoragePoolEventRegisterAny(vi= rNetServerPtr server ATTRIBUT struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virStoragePoolPtr pool =3D NULL; - - if (!priv->storageConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetStorageConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + if (args->pool && - !(pool =3D get_nonnull_storage_pool(priv->storageConn, *args->pool= ))) + !(pool =3D get_nonnull_storage_pool(conn, *args->pool))) goto cleanup; =20 if (args->eventID >=3D VIR_STORAGE_POOL_EVENT_ID_LAST || args->eventID= < 0) { @@ -6244,7 +6071,7 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virN= etServerPtr server ATTRIBUT callback) < 0) goto cleanup; =20 - if ((callbackID =3D virConnectStoragePoolEventRegisterAny(priv->storag= eConn, + if ((callbackID =3D virConnectStoragePoolEventRegisterAny(conn, pool, args->eventID, storageEventCa= llbacks[args->eventID], @@ -6281,14 +6108,13 @@ remoteDispatchConnectStoragePoolEventDeregisterAny(= virNetServerPtr server ATTRIB size_t i; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->storageConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetStorageConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + for (i =3D 0; i < priv->nstorageEventCallbacks; i++) { if (priv->storageEventCallbacks[i]->callbackID =3D=3D args->callba= ckID) break; @@ -6300,7 +6126,7 @@ remoteDispatchConnectStoragePoolEventDeregisterAny(vi= rNetServerPtr server ATTRIB goto cleanup; } =20 - if (virConnectStoragePoolEventDeregisterAny(priv->storageConn, args->c= allbackID) < 0) + if (virConnectStoragePoolEventDeregisterAny(conn, args->callbackID) < = 0) goto cleanup; =20 VIR_DELETE_ELEMENT(priv->storageEventCallbacks, i, @@ -6330,16 +6156,15 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(vir= NetServerPtr server ATTRIBUTE struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virNodeDevicePtr dev =3D NULL; - - if (!priv->nodedevConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetNodeDevConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + if (args->dev && - !(dev =3D get_nonnull_node_device(priv->nodedevConn, *args->dev))) + !(dev =3D get_nonnull_node_device(conn, *args->dev))) goto cleanup; =20 if (args->eventID >=3D VIR_NODE_DEVICE_EVENT_ID_LAST || args->eventID = < 0) { @@ -6365,7 +6190,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNe= tServerPtr server ATTRIBUTE callback) < 0) goto cleanup; =20 - if ((callbackID =3D virConnectNodeDeviceEventRegisterAny(priv->nodedev= Conn, + if ((callbackID =3D virConnectNodeDeviceEventRegisterAny(conn, dev, args->eventID, nodeDeviceEvent= Callbacks[args->eventID], @@ -6402,14 +6227,13 @@ remoteDispatchConnectNodeDeviceEventDeregisterAny(v= irNetServerPtr server ATTRIBU size_t i; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->nodedevConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetNodeDevConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + for (i =3D 0; i < priv->nnodeDeviceEventCallbacks; i++) { if (priv->nodeDeviceEventCallbacks[i]->callbackID =3D=3D args->cal= lbackID) break; @@ -6421,7 +6245,7 @@ remoteDispatchConnectNodeDeviceEventDeregisterAny(vir= NetServerPtr server ATTRIBU goto cleanup; } =20 - if (virConnectNodeDeviceEventDeregisterAny(priv->nodedevConn, args->ca= llbackID) < 0) + if (virConnectNodeDeviceEventDeregisterAny(conn, args->callbackID) < 0) goto cleanup; =20 VIR_DELETE_ELEMENT(priv->nodeDeviceEventCallbacks, i, @@ -6451,16 +6275,15 @@ remoteDispatchConnectSecretEventRegisterAny(virNetS= erverPtr server ATTRIBUTE_UNU struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virSecretPtr secret =3D NULL; - - if (!priv->secretConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetSecretConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + if (args->secret && - !(secret =3D get_nonnull_secret(priv->secretConn, *args->secret))) + !(secret =3D get_nonnull_secret(conn, *args->secret))) goto cleanup; =20 if (args->eventID >=3D VIR_SECRET_EVENT_ID_LAST || args->eventID < 0) { @@ -6486,7 +6309,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetSer= verPtr server ATTRIBUTE_UNU callback) < 0) goto cleanup; =20 - if ((callbackID =3D virConnectSecretEventRegisterAny(priv->secretConn, + if ((callbackID =3D virConnectSecretEventRegisterAny(conn, secret, args->eventID, secretEventCallback= s[args->eventID], @@ -6523,14 +6346,13 @@ remoteDispatchConnectSecretEventDeregisterAny(virNe= tServerPtr server ATTRIBUTE_U size_t i; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->secretConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetSecretConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + for (i =3D 0; i < priv->nsecretEventCallbacks; i++) { if (priv->secretEventCallbacks[i]->callbackID =3D=3D args->callbac= kID) break; @@ -6542,7 +6364,7 @@ remoteDispatchConnectSecretEventDeregisterAny(virNetS= erverPtr server ATTRIBUTE_U goto cleanup; } =20 - if (virConnectSecretEventDeregisterAny(priv->secretConn, args->callbac= kID) < 0) + if (virConnectSecretEventDeregisterAny(conn, args->callbackID) < 0) goto cleanup; =20 VIR_DELETE_ELEMENT(priv->secretEventCallbacks, i, @@ -6573,16 +6395,15 @@ qemuDispatchConnectDomainMonitorEventRegister(virNe= tServerPtr server ATTRIBUTE_U virNetServerClientGetPrivateData(client); virDomainPtr dom =3D NULL; const char *event =3D args->event ? *args->event : NULL; - - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + if (args->dom && - !(dom =3D get_nonnull_domain(priv->conn, *args->dom))) + !(dom =3D get_nonnull_domain(conn, *args->dom))) goto cleanup; =20 /* If we call register first, we could append a complete callback @@ -6602,7 +6423,7 @@ qemuDispatchConnectDomainMonitorEventRegister(virNetS= erverPtr server ATTRIBUTE_U callback) < 0) goto cleanup; =20 - if ((callbackID =3D virConnectDomainQemuMonitorEventRegister(priv->con= n, + if ((callbackID =3D virConnectDomainQemuMonitorEventRegister(conn, dom, event, remoteRelay= DomainQemuMonitorEvent, @@ -6641,14 +6462,13 @@ qemuDispatchConnectDomainMonitorEventDeregister(vir= NetServerPtr server ATTRIBUTE size_t i; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); - - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); - goto cleanup; - } + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 virMutexLock(&priv->lock); =20 + if (!conn) + goto cleanup; + for (i =3D 0; i < priv->nqemuEventCallbacks; i++) { if (priv->qemuEventCallbacks[i]->callbackID =3D=3D args->callbackI= D) break; @@ -6660,7 +6480,7 @@ qemuDispatchConnectDomainMonitorEventDeregister(virNe= tServerPtr server ATTRIBUTE goto cleanup; } =20 - if (virConnectDomainQemuMonitorEventDeregister(priv->conn, + if (virConnectDomainQemuMonitorEventDeregister(conn, args->callbackID) < 0) goto cleanup; =20 @@ -6688,15 +6508,12 @@ remoteDispatchDomainGetTime(virNetServerPtr server = ATTRIBUTE_UNUSED, virDomainPtr dom =3D NULL; long long seconds; unsigned int nseconds; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if (virDomainGetTime(dom, &seconds, &nseconds, args->flags) < 0) @@ -6724,13 +6541,10 @@ remoteDispatchNodeGetFreePages(virNetServerPtr serv= er ATTRIBUTE_UNUSED, { int rv =3D -1; int len; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->pages.pages_len * args->cellCount > REMOTE_NODE_MAX_CELLS) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -6743,7 +6557,7 @@ remoteDispatchNodeGetFreePages(virNetServerPtr server= ATTRIBUTE_UNUSED, args->pages.pages_len * args->cellCount) < 0) goto cleanup; =20 - if ((len =3D virNodeGetFreePages(priv->conn, + if ((len =3D virNodeGetFreePages(conn, args->pages.pages_len, args->pages.pages_val, args->startCell, @@ -6837,17 +6651,15 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr = server ATTRIBUTE_UNUSED, { int rv =3D -1; size_t i; - struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(= client); virNetworkDHCPLeasePtr *leases =3D NULL; virNetworkPtr net =3D NULL; int nleases =3D 0; + virConnectPtr conn =3D remoteGetNetworkConn(client); =20 - if (!priv->networkConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(net =3D get_nonnull_network(priv->networkConn, args->net))) + if (!(net =3D get_nonnull_network(conn, args->net))) goto cleanup; =20 if ((nleases =3D virNetworkGetDHCPLeases(net, @@ -6905,22 +6717,20 @@ remoteDispatchConnectGetAllDomainStats(virNetServer= Ptr server ATTRIBUTE_UNUSED, { int rv =3D -1; size_t i; - struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(= client); virDomainStatsRecordPtr *retStats =3D NULL; int nrecords =3D 0; virDomainPtr *doms =3D NULL; + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 if (args->doms.doms_len) { if (VIR_ALLOC_N(doms, args->doms.doms_len + 1) < 0) goto cleanup; =20 for (i =3D 0; i < args->doms.doms_len; i++) { - if (!(doms[i] =3D get_nonnull_domain(priv->conn, args->doms.do= ms_val[i]))) + if (!(doms[i] =3D get_nonnull_domain(conn, args->doms.doms_val= [i]))) goto cleanup; } =20 @@ -6930,7 +6740,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPt= r server ATTRIBUTE_UNUSED, args->flags)) < 0) goto cleanup; } else { - if ((nrecords =3D virConnectGetAllDomainStats(priv->conn, + if ((nrecords =3D virConnectGetAllDomainStats(conn, args->stats, &retStats, args->flags)) < 0) @@ -6992,15 +6802,12 @@ remoteDispatchNodeAllocPages(virNetServerPtr server= ATTRIBUTE_UNUSED, { int rv =3D -1; int len; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if ((len =3D virNodeAllocPages(priv->conn, + if ((len =3D virNodeAllocPages(conn, args->pageSizes.pageSizes_len, args->pageSizes.pageSizes_val, (unsigned long long *) args->pageCounts.p= ageCounts_val, @@ -7029,19 +6836,17 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr serve= r ATTRIBUTE_UNUSED, { int rv =3D -1; size_t i, j; - struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(= client); virDomainFSInfoPtr *info =3D NULL; virDomainPtr dom =3D NULL; remote_domain_fsinfo *dst; int ninfo =3D 0; size_t ndisk; + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if ((ninfo =3D virDomainGetFSInfo(dom, &info, args->flags)) < 0) @@ -7226,15 +7031,12 @@ remoteDispatchDomainInterfaceAddresses(virNetServer= Ptr server ATTRIBUTE_UNUSED, virDomainPtr dom =3D NULL; virDomainInterfacePtr *ifaces =3D NULL; int ifaces_count =3D 0; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 - if (!priv->conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 if ((ifaces_count =3D virDomainInterfaceAddresses(dom, &ifaces, args->= source, args->flags)) < 0) @@ -7272,15 +7074,12 @@ remoteDispatchStorageVolGetInfoFlags(virNetServerPt= r server ATTRIBUTE_UNUSED, int rv =3D -1; virStorageVolPtr vol =3D NULL; virStorageVolInfo tmp; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetStorageConn(client); =20 - if (!priv->storageConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(vol =3D get_nonnull_storage_vol(priv->storageConn, args->vol))) + if (!(vol =3D get_nonnull_storage_vol(conn, args->vol))) goto cleanup; =20 if (virStorageVolGetInfoFlags(vol, &tmp, args->flags) < 0) @@ -7311,15 +7110,12 @@ remoteDispatchNetworkPortGetParameters(virNetServer= Ptr server ATTRIBUTE_UNUSED, virNetworkPortPtr port =3D NULL; virTypedParameterPtr params =3D NULL; int nparams =3D 0; - struct daemonClientPrivate *priv =3D - virNetServerClientGetPrivateData(client); + virConnectPtr conn =3D remoteGetNetworkConn(client); =20 - if (!priv->networkConn) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + if (!conn) goto cleanup; - } =20 - if (!(port =3D get_nonnull_network_port(priv->networkConn, args->port)= )) + if (!(port =3D get_nonnull_network_port(conn, args->port))) goto cleanup; =20 if (virNetworkPortGetParameters(port, ¶ms, &nparams, args->flags) = < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list