From nobody Sun Feb 8 19:39:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1572629825; cv=none; d=zoho.com; s=zohoarc; b=cGVw1tMQ6xkeAqu3/gdaWt0EcO96WZLvZSnlJzZCuEwygVRhsKDPhTYF1EcXf6SJ5BjkojsIIw8EEybVA9hYSXoFtQEtdZc1tFP6AmpVbbeT1s12zhuh4ZEeNlcriBv5RmIf/tOsPy7NEsd+PgH46oqhiexeDQwglzhI59eH7Gk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572629825; h=Content-Type:Content-Transfer-Encoding:Cc: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; bh=JvvfF9hc1yqLdy9/efbFTUX0W3Rl4MjjjINKbZrd5bc=; b=jDKHTPjWEYvNJljCF0rpolLeDFsfl690KeUz5K9uFcBxGvKrA3TOrdxu3tQgiNL/ejoqMwfxqyHGHQAMPts3ymGZb3MBMEURie47NUDEp6Vnn6x2NZtc1tOT2V21KEAZPp69RYitVCfzyfl1kOgw+dGku2RZoGBgnz/yvXRSK5A= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1572629825909588.5543644345516; Fri, 1 Nov 2019 10:37:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-54OgEYpTML6Be8nw03WySA-1; Fri, 01 Nov 2019 13:36:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0A511005513; Fri, 1 Nov 2019 17:36:43 +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 8F6885C28E; Fri, 1 Nov 2019 17:36:43 +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 4DDDF4E566; Fri, 1 Nov 2019 17:36:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xA1HaHG3028024 for ; Fri, 1 Nov 2019 13:36:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 424F05D6D8; Fri, 1 Nov 2019 17:36:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx29.extmail.prod.ext.phx2.redhat.com [10.5.110.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CEB45D6B7 for ; Fri, 1 Nov 2019 17:36:17 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2293118C786C for ; Fri, 1 Nov 2019 17:36:16 +0000 (UTC) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id xA1Grl4p041671 for ; Fri, 1 Nov 2019 13:36:15 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w0r7whyhq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Nov 2019 13:36:15 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Nov 2019 17:36:13 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 1 Nov 2019 17:36:10 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xA1Ha9aM52691182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Nov 2019 17:36:09 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F17B42047; Fri, 1 Nov 2019 17:36:09 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C75B742042; Fri, 1 Nov 2019 17:36:08 +0000 (GMT) Received: from marcibm.ibmuc.com (unknown [9.145.5.215]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Nov 2019 17:36:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572629822; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JvvfF9hc1yqLdy9/efbFTUX0W3Rl4MjjjINKbZrd5bc=; b=DufEUtR+fNMXoFZ6DFp6Z2V+rSqDJWAMMRJUapDLUKz709Nrw0CrNtzJHy/tHUExwJeRG2 Neb4ZmQyQr3/qKPwZEmKyxVzS52zxumbggRKsB59BhknOiFBu/ktJF6WP4tNPvSCC5nSbM 4XdfyPqfQyw5j+mgrzbIENeYnxBOgjw= From: Marc Hartmayer To: Date: Fri, 1 Nov 2019 18:35:48 +0100 In-Reply-To: <20191101173548.7888-1-mhartmay@linux.ibm.com> References: <20191101173548.7888-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19110117-4275-0000-0000-00000379EF56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19110117-4276-0000-0000-0000388D31F8 Message-Id: <20191101173548.7888-7-mhartmay@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-11-01_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1911010158 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Fri, 01 Nov 2019 17:36:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Fri, 01 Nov 2019 17:36:16 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'mhartmay@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.70 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa , Pavel Hrdina Subject: [libvirt] [PATCH v3 6/6] remote/rpc: Use virNetServerGetProgram() to determine the program 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: 54OgEYpTML6Be8nw03WySA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use virNetServerGetProgram() to determine the virNetServerProgram instead of using hard coded global variables. This allows us to remove the global variables @remoteProgram and @qemuProgram as they're now no longer necessary. Signed-off-by: Marc Hartmayer --- src/libvirt_remote.syms | 1 + src/remote/remote_daemon.c | 4 +- src/remote/remote_daemon.h | 2 - src/remote/remote_daemon_dispatch.c | 118 +++++++++++++++++++++------- src/rpc/gendispatch.pl | 6 ++ src/rpc/virnetserver.c | 22 ++++++ src/rpc/virnetserver.h | 2 + 7 files changed, 122 insertions(+), 33 deletions(-) diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index 0493467f4603..a6883f373608 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -124,6 +124,7 @@ virNetServerGetCurrentUnauthClients; virNetServerGetMaxClients; virNetServerGetMaxUnauthClients; virNetServerGetName; +virNetServerGetProgram; virNetServerGetThreadPoolParameters; virNetServerHasClients; virNetServerNeedsAuth; diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index 7e63e180344d..c8ac224d52e9 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -73,8 +73,6 @@ VIR_LOG_INIT("daemon." DAEMON_NAME); #if WITH_SASL virNetSASLContextPtr saslCtxt =3D NULL; #endif -virNetServerProgramPtr remoteProgram =3D NULL; -virNetServerProgramPtr qemuProgram =3D NULL; =20 volatile bool driversInitialized =3D false; =20 @@ -1007,6 +1005,8 @@ int main(int argc, char **argv) { virNetServerPtr srv =3D NULL; virNetServerPtr srvAdm =3D NULL; virNetServerProgramPtr adminProgram =3D NULL; + virNetServerProgramPtr qemuProgram =3D NULL; + virNetServerProgramPtr remoteProgram =3D NULL; virNetServerProgramPtr lxcProgram =3D NULL; char *remote_config_file =3D NULL; int statuswrite =3D -1; diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h index a2d9af403619..a3d6a220f868 100644 --- a/src/remote/remote_daemon.h +++ b/src/remote/remote_daemon.h @@ -97,5 +97,3 @@ struct daemonClientPrivate { #if WITH_SASL extern virNetSASLContextPtr saslCtxt; #endif -extern virNetServerProgramPtr remoteProgram; -extern virNetServerProgramPtr qemuProgram; diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 70f1f7d815e8..8756bd1a222d 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -4170,9 +4170,9 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr ser= ver G_GNUC_UNUSED, } =20 static int -remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server G_GNUC_U= NUSED, +remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg G_GNUC_UNU= SED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr) { int rv =3D -1; @@ -4180,6 +4180,12 @@ remoteDispatchConnectRegisterCloseCallback(virNetSer= verPtr server G_GNUC_UNUSED, struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virConnectPtr conn =3D remoteGetHypervisorConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -4190,7 +4196,7 @@ remoteDispatchConnectRegisterCloseCallback(virNetServ= erPtr server G_GNUC_UNUSED, goto cleanup; =20 callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(remoteProgram); + callback->program =3D virObjectRef(program); /* eventID, callbackID, and legacy are not used */ callback->eventID =3D -1; callback->callbackID =3D -1; @@ -4242,9 +4248,9 @@ remoteDispatchConnectUnregisterCloseCallback(virNetSe= rverPtr server G_GNUC_UNUSE } =20 static int -remoteDispatchConnectDomainEventRegister(virNetServerPtr server G_GNUC_UNU= SED, +remoteDispatchConnectDomainEventRegister(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg G_GNUC_UNUSE= D, + virNetMessagePtr msg, virNetMessageErrorPtr rerr G_GNUC= _UNUSED, remote_connect_domain_event_regis= ter_ret *ret G_GNUC_UNUSED) { @@ -4255,6 +4261,12 @@ remoteDispatchConnectDomainEventRegister(virNetServe= rPtr server G_GNUC_UNUSED, struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virConnectPtr conn =3D remoteGetHypervisorConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -4272,7 +4284,7 @@ remoteDispatchConnectDomainEventRegister(virNetServer= Ptr server G_GNUC_UNUSED, if (VIR_ALLOC(callback) < 0) goto cleanup; callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(remoteProgram); + callback->program =3D virObjectRef(program); callback->eventID =3D VIR_DOMAIN_EVENT_ID_LIFECYCLE; callback->callbackID =3D -1; callback->legacy =3D true; @@ -4463,9 +4475,9 @@ remoteDispatchDomainGetState(virNetServerPtr server G= _GNUC_UNUSED, * VIR_DRV_SUPPORTS_FEATURE(VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK), * and must not mix the two styles. */ static int -remoteDispatchConnectDomainEventRegisterAny(virNetServerPtr server G_GNUC_= UNUSED, +remoteDispatchConnectDomainEventRegisterAny(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg G_GNUC_UN= USED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr G_G= NUC_UNUSED, remote_connect_domain_event_re= gister_any_args *args) { @@ -4476,6 +4488,12 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSe= rverPtr server G_GNUC_UNUSED struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virConnectPtr conn =3D remoteGetHypervisorConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -4501,7 +4519,7 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSer= verPtr server G_GNUC_UNUSED if (VIR_ALLOC(callback) < 0) goto cleanup; callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(remoteProgram); + callback->program =3D virObjectRef(program); callback->eventID =3D args->eventID; callback->callbackID =3D -1; callback->legacy =3D true; @@ -4537,9 +4555,9 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSer= verPtr server G_GNUC_UNUSED =20 =20 static int -remoteDispatchConnectDomainEventCallbackRegisterAny(virNetServerPtr server= G_GNUC_UNUSED, +remoteDispatchConnectDomainEventCallbackRegisterAny(virNetServerPtr server, virNetServerClientPtr = client, - virNetMessagePtr msg G= _GNUC_UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr = rerr G_GNUC_UNUSED, remote_connect_domain_= event_callback_register_any_args *args, remote_connect_domain_= event_callback_register_any_ret *ret) @@ -4552,6 +4570,12 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(= virNetServerPtr server G_GNU virNetServerClientGetPrivateData(client); virDomainPtr dom =3D NULL; virConnectPtr conn =3D remoteGetHypervisorConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -4577,7 +4601,7 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(v= irNetServerPtr server G_GNU if (VIR_ALLOC(callback) < 0) goto cleanup; callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(remoteProgram); + callback->program =3D virObjectRef(program); callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; @@ -5647,7 +5671,7 @@ remoteDispatchDomainMigratePrepare3Params(virNetServe= rPtr server G_GNUC_UNUSED, } =20 static int -remoteDispatchDomainMigratePrepareTunnel3Params(virNetServerPtr server G_G= NUC_UNUSED, +remoteDispatchDomainMigratePrepareTunnel3Params(virNetServerPtr server, virNetServerClientPtr clie= nt, virNetMessagePtr msg, virNetMessageErrorPtr rerr, @@ -5662,6 +5686,7 @@ remoteDispatchDomainMigratePrepareTunnel3Params(virNe= tServerPtr server G_GNUC_UN virStreamPtr st =3D NULL; daemonClientStreamPtr stream =3D NULL; virConnectPtr conn =3D remoteGetHypervisorConn(client); + virNetServerProgramPtr program; =20 if (!conn) goto cleanup; @@ -5678,8 +5703,13 @@ remoteDispatchDomainMigratePrepareTunnel3Params(virN= etServerPtr server G_GNUC_UN 0, ¶ms, &nparams) < 0) goto cleanup; =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + if (!(st =3D virStreamNew(conn, VIR_STREAM_NONBLOCK)) || - !(stream =3D daemonCreateClientStream(client, st, remoteProgram, + !(stream =3D daemonCreateClientStream(client, st, program, &msg->header, false))) goto cleanup; =20 @@ -6020,9 +6050,9 @@ static int remoteDispatchDomainCreateWithFiles(virNet= ServerPtr server G_GNUC_UNU =20 =20 static int -remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server G_GNUC= _UNUSED, +remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg G_GNUC_U= NUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr G_= GNUC_UNUSED, remote_connect_network_event_= register_any_args *args, remote_connect_network_event_= register_any_ret *ret) @@ -6035,6 +6065,12 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetS= erverPtr server G_GNUC_UNUSE struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virConnectPtr conn =3D remoteGetNetworkConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -6060,7 +6096,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetSe= rverPtr server G_GNUC_UNUSE if (VIR_ALLOC(callback) < 0) goto cleanup; callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(remoteProgram); + callback->program =3D virObjectRef(program); callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; @@ -6141,9 +6177,9 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNet= ServerPtr server G_GNUC_UNU } =20 static int -remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server G_= GNUC_UNUSED, +remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server, virNetServerClientPtr cli= ent, - virNetMessagePtr msg G_GN= UC_UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rer= r G_GNUC_UNUSED, remote_connect_storage_po= ol_event_register_any_args *args, remote_connect_storage_po= ol_event_register_any_ret *ret) @@ -6156,6 +6192,12 @@ remoteDispatchConnectStoragePoolEventRegisterAny(vir= NetServerPtr server G_GNUC_U virNetServerClientGetPrivateData(client); virStoragePoolPtr pool =3D NULL; virConnectPtr conn =3D remoteGetStorageConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -6181,7 +6223,7 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virN= etServerPtr server G_GNUC_U if (VIR_ALLOC(callback) < 0) goto cleanup; callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(remoteProgram); + callback->program =3D virObjectRef(program); callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; @@ -6261,9 +6303,9 @@ remoteDispatchConnectStoragePoolEventDeregisterAny(vi= rNetServerPtr server G_GNUC } =20 static int -remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server G_G= NUC_UNUSED, +remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server, virNetServerClientPtr clie= nt, - virNetMessagePtr msg G_GNU= C_UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr= G_GNUC_UNUSED, remote_connect_node_device= _event_register_any_args *args, remote_connect_node_device= _event_register_any_ret *ret) @@ -6276,6 +6318,12 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virN= etServerPtr server G_GNUC_UN virNetServerClientGetPrivateData(client); virNodeDevicePtr dev =3D NULL; virConnectPtr conn =3D remoteGetNodeDevConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -6301,7 +6349,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNe= tServerPtr server G_GNUC_UN if (VIR_ALLOC(callback) < 0) goto cleanup; callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(remoteProgram); + callback->program =3D virObjectRef(program); callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; @@ -6381,9 +6429,9 @@ remoteDispatchConnectNodeDeviceEventDeregisterAny(vir= NetServerPtr server G_GNUC_ } =20 static int -remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server G_GNUC_= UNUSED, +remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg G_GNUC_UN= USED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr G_G= NUC_UNUSED, remote_connect_secret_event_re= gister_any_args *args, remote_connect_secret_event_re= gister_any_ret *ret) @@ -6396,6 +6444,12 @@ remoteDispatchConnectSecretEventRegisterAny(virNetSe= rverPtr server G_GNUC_UNUSED virNetServerClientGetPrivateData(client); virSecretPtr secret =3D NULL; virConnectPtr conn =3D remoteGetSecretConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -6421,7 +6475,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetSer= verPtr server G_GNUC_UNUSED if (VIR_ALLOC(callback) < 0) goto cleanup; callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(remoteProgram); + callback->program =3D virObjectRef(program); callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; @@ -6501,9 +6555,9 @@ remoteDispatchConnectSecretEventDeregisterAny(virNetS= erverPtr server G_GNUC_UNUS } =20 static int -qemuDispatchConnectDomainMonitorEventRegister(virNetServerPtr server G_GNU= C_UNUSED, +qemuDispatchConnectDomainMonitorEventRegister(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg G_GNUC_= UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr G= _GNUC_UNUSED, qemu_connect_domain_monitor_= event_register_args *args, qemu_connect_domain_monitor_= event_register_ret *ret) @@ -6517,6 +6571,12 @@ qemuDispatchConnectDomainMonitorEventRegister(virNet= ServerPtr server G_GNUC_UNUS virDomainPtr dom =3D NULL; const char *event =3D args->event ? *args->event : NULL; virConnectPtr conn =3D remoteGetHypervisorConn(client); + virNetServerProgramPtr program; + + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } =20 virMutexLock(&priv->lock); =20 @@ -6536,7 +6596,7 @@ qemuDispatchConnectDomainMonitorEventRegister(virNetS= erverPtr server G_GNUC_UNUS if (VIR_ALLOC(callback) < 0) goto cleanup; callback->client =3D virObjectRef(client); - callback->program =3D virObjectRef(qemuProgram); + callback->program =3D virObjectRef(program); callback->eventID =3D -1; callback->callbackID =3D -1; ref =3D callback; diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 7c868191d19c..2b8795beec16 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -1052,6 +1052,7 @@ elsif ($mode eq "server") { if ($call->{streamflag} ne "none") { print " virStreamPtr st =3D NULL;\n"; print " daemonClientStreamPtr stream =3D NULL;\n"; + print " virNetServerProgramPtr remoteProgram;\n"; if ($call->{sparseflag} ne "none") { print " const bool sparse =3D args->flags & $call->{spa= rseflag};\n" } else { @@ -1093,6 +1094,11 @@ elsif ($mode eq "server") { print " if (!(st =3D virStreamNew($conn_var, VIR_STREAM_NON= BLOCK)))\n"; print " goto cleanup;\n"; print "\n"; + print " if (!(remoteProgram =3D virNetServerGetProgram(serv= er, msg))) {\n"; + print " virReportError(VIR_ERR_INTERNAL_ERROR, \"%s\", = _(\"no matching program found\"));\n"; + print " goto cleanup;\n"; + print " }\n"; + print "\n"; print " if (!(stream =3D daemonCreateClientStream(client, s= t, remoteProgram, &msg->header, sparse)))\n"; print " goto cleanup;\n"; print "\n"; diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 154747a1a097..80a28123c536 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -192,6 +192,28 @@ virNetServerGetProgramLocked(virNetServerPtr srv, return NULL; } =20 +/** + * virNetServerGetProgram: + * @srv: server (must NOT be locked by the caller) + * @msg: message + * + * Searches @srv for the right program for a given message @msg. + * + * Returns a pointer to the server program or NULL if not found. + */ +virNetServerProgramPtr +virNetServerGetProgram(virNetServerPtr srv, + virNetMessagePtr msg) +{ + virNetServerProgramPtr ret; + + virObjectLock(srv); + ret =3D virNetServerGetProgramLocked(srv, msg); + virObjectUnlock(srv); + + return ret; +} + static void virNetServerDispatchNewMessage(virNetServerClientPtr client, virNetMessagePtr msg, diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h index 260c99b22d5e..46ecb0e91077 100644 --- a/src/rpc/virnetserver.h +++ b/src/rpc/virnetserver.h @@ -90,6 +90,8 @@ int virNetServerAddProgram(virNetServerPtr srv, int virNetServerSetTLSContext(virNetServerPtr srv, virNetTLSContextPtr tls); =20 +virNetServerProgramPtr virNetServerGetProgram(virNetServerPtr srv, + virNetMessagePtr msg); =20 int virNetServerAddClient(virNetServerPtr srv, virNetServerClientPtr client); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list