From nobody Mon Feb 9 08:28:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523781442873523.907429175583; Sun, 15 Apr 2018 01:37:22 -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 9E8873247C1C; Sun, 15 Apr 2018 08:37:21 +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 5F1A75D6A2; Sun, 15 Apr 2018 08:37:21 +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 158EF1805972; Sun, 15 Apr 2018 08:37:21 +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 w3CCfNCi013414 for ; Thu, 12 Apr 2018 08:41:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 341CD78DD6; Thu, 12 Apr 2018 12:41:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 295017E028 for ; Thu, 12 Apr 2018 12:41:22 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 0EB04313066B for ; Thu, 12 Apr 2018 12:41:21 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3CCdTr4001843 for ; Thu, 12 Apr 2018 08:41:20 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ha49g9kad-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 12 Apr 2018 08:41:20 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Apr 2018 13:41:18 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Apr 2018 13:41:16 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3CCfFs151642374 for ; Thu, 12 Apr 2018 12:41:15 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E02242041 for ; Thu, 12 Apr 2018 13:32:56 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 281974204B for ; Thu, 12 Apr 2018 13:32:56 +0100 (BST) Received: from marc-ibm.boeblingen.de.ibm.com (unknown [9.152.224.71]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Thu, 12 Apr 2018 13:32:56 +0100 (BST) From: Marc Hartmayer To: Date: Thu, 12 Apr 2018 14:41:01 +0200 In-Reply-To: <20180412124104.10547-1-mhartmay@linux.vnet.ibm.com> References: <20180412124104.10547-1-mhartmay@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041212-0040-0000-0000-0000044CBE94 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041212-0041-0000-0000-000020F0F260 Message-Id: <20180412124104.10547-7-mhartmay@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-12_07:, , 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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804120127 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 12 Apr 2018 12:41:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 12 Apr 2018 12:41:21 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'mhartmay@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.699 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH libvirt v2 6/9] 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: , MIME-Version: 1.0 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.41]); Sun, 15 Apr 2018 08:37:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 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 Reviewed-by: Boris Fiuczynski Reviewed-by: John Ferlan --- Note: I'm not 100% sure that there is no case where the lock for @client is already held by the thread which is calling virNetServerGetProgram and thus the lock order would be violated (the lock order has to be @server -> @client in the violating case it would be @client -> @server and therefore a deadlock might occur). --- src/libvirt_remote.syms | 1 + src/remote/remote_daemon.c | 4 +- src/remote/remote_daemon.h | 3 - src/remote/remote_daemon_dispatch.c | 116 +++++++++++++++++++++++++++-----= ---- src/rpc/gendispatch.pl | 6 ++ src/rpc/virnetserver.c | 23 +++++++ 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 97e22275b980..c31b16cd5909 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -120,6 +120,7 @@ virNetServerGetCurrentUnauthClients; virNetServerGetMaxClients; virNetServerGetMaxUnauthClients; virNetServerGetName; +virNetServerGetProgram; virNetServerGetThreadPoolParameters; virNetServerHasClients; virNetServerNew; diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index 31c6ce1b6179..f854a1a6981e 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -71,8 +71,6 @@ VIR_LOG_INIT("daemon.libvirtd"); #if WITH_SASL virNetSASLContextPtr saslCtxt =3D NULL; #endif -virNetServerProgramPtr remoteProgram =3D NULL; -virNetServerProgramPtr qemuProgram =3D NULL; =20 volatile bool driversInitialized =3D false; =20 @@ -1049,6 +1047,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 2834da04a9ae..a2eda209683b 100644 --- a/src/remote/remote_daemon.h +++ b/src/remote/remote_daemon.h @@ -88,7 +88,4 @@ struct daemonClientPrivate { # if WITH_SASL extern virNetSASLContextPtr saslCtxt; # endif -extern virNetServerProgramPtr remoteProgram; -extern virNetServerProgramPtr qemuProgram; - #endif /* __REMOTE_DAEMON_H__ */ diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index cf2cd0add7d6..94b9cc3377d8 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -3830,15 +3830,16 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr s= erver ATTRIBUTE_UNUSED, } =20 static int -remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server ATTRIBUT= E_UNUSED, +remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg ATTRIBUTE_= UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr) { int rv =3D -1; daemonClientEventCallbackPtr callback =3D NULL; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); + virNetServerProgramPtr program; =20 virMutexLock(&priv->lock); =20 @@ -3847,10 +3848,15 @@ remoteDispatchConnectRegisterCloseCallback(virNetSe= rverPtr server ATTRIBUTE_UNUS goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + if (VIR_ALLOC(callback) < 0) goto cleanup; 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; @@ -3903,9 +3909,9 @@ remoteDispatchConnectUnregisterCloseCallback(virNetSe= rverPtr server ATTRIBUTE_UN } =20 static int -remoteDispatchConnectDomainEventRegister(virNetServerPtr server ATTRIBUTE_= UNUSED, +remoteDispatchConnectDomainEventRegister(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg ATTRIBUTE_UN= USED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr ATTRIB= UTE_UNUSED, remote_connect_domain_event_regis= ter_ret *ret ATTRIBUTE_UNUSED) { @@ -3915,12 +3921,18 @@ remoteDispatchConnectDomainEventRegister(virNetServ= erPtr server ATTRIBUTE_UNUSED daemonClientEventCallbackPtr ref; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); + virNetServerProgramPtr program; =20 if (!priv->conn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + virMutexLock(&priv->lock); =20 /* If we call register first, we could append a complete callback @@ -3934,7 +3946,7 @@ remoteDispatchConnectDomainEventRegister(virNetServer= Ptr server ATTRIBUTE_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; @@ -4132,9 +4144,9 @@ remoteDispatchDomainGetState(virNetServerPtr server A= TTRIBUTE_UNUSED, * VIR_DRV_SUPPORTS_FEATURE(VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK), * and must not mix the two styles. */ static int -remoteDispatchConnectDomainEventRegisterAny(virNetServerPtr server ATTRIBU= TE_UNUSED, +remoteDispatchConnectDomainEventRegisterAny(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg ATTRIBUTE= _UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr ATT= RIBUTE_UNUSED, remote_connect_domain_event_re= gister_any_args *args) { @@ -4144,12 +4156,18 @@ remoteDispatchConnectDomainEventRegisterAny(virNetS= erverPtr server ATTRIBUTE_UNU daemonClientEventCallbackPtr ref; struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); + virNetServerProgramPtr program; =20 if (!priv->conn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + virMutexLock(&priv->lock); =20 /* We intentionally do not use VIR_DOMAIN_EVENT_ID_LAST here; any @@ -4171,7 +4189,7 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSer= verPtr server ATTRIBUTE_UNU 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; @@ -4207,9 +4225,9 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSer= verPtr server ATTRIBUTE_UNU =20 =20 static int -remoteDispatchConnectDomainEventCallbackRegisterAny(virNetServerPtr server= ATTRIBUTE_UNUSED, +remoteDispatchConnectDomainEventCallbackRegisterAny(virNetServerPtr server, virNetServerClientPtr = client, - virNetMessagePtr msg A= TTRIBUTE_UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr = rerr ATTRIBUTE_UNUSED, remote_connect_domain_= event_callback_register_any_args *args, remote_connect_domain_= event_callback_register_any_ret *ret) @@ -4221,12 +4239,18 @@ remoteDispatchConnectDomainEventCallbackRegisterAny= (virNetServerPtr server ATTRI struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virDomainPtr dom =3D NULL; + virNetServerProgramPtr program; =20 if (!priv->conn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + virMutexLock(&priv->lock); =20 if (args->dom && @@ -4248,7 +4272,7 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(v= irNetServerPtr server ATTRI 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; @@ -5355,6 +5379,7 @@ remoteDispatchDomainMigratePrepareTunnel3Params(virNe= tServerPtr server ATTRIBUTE virNetServerClientGetPrivateData(client); virStreamPtr st =3D NULL; daemonClientStreamPtr stream =3D NULL; + virNetServerProgramPtr program; =20 if (!priv->conn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); @@ -5373,8 +5398,13 @@ remoteDispatchDomainMigratePrepareTunnel3Params(virN= etServerPtr server ATTRIBUTE 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(priv->conn, VIR_STREAM_NONBLOCK)) || - !(stream =3D daemonCreateClientStream(client, st, remoteProgram, + !(stream =3D daemonCreateClientStream(client, st, program, &msg->header, false))) goto cleanup; =20 @@ -5731,9 +5761,9 @@ static int remoteDispatchDomainCreateWithFiles(virNet= ServerPtr server ATTRIBUTE_ =20 =20 static int -remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIB= UTE_UNUSED, +remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg ATTRIBUT= E_UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr AT= TRIBUTE_UNUSED, remote_connect_network_event_= register_any_args *args, remote_connect_network_event_= register_any_ret *ret) @@ -5745,12 +5775,18 @@ remoteDispatchConnectNetworkEventRegisterAny(virNet= ServerPtr server ATTRIBUTE_UN struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virNetworkPtr net =3D NULL; + virNetServerProgramPtr program; =20 if (!priv->networkConn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + virMutexLock(&priv->lock); =20 if (args->net && @@ -5772,7 +5808,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetSe= rverPtr server ATTRIBUTE_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; @@ -5854,9 +5890,9 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNet= ServerPtr server ATTRIBUTE_ } =20 static int -remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server AT= TRIBUTE_UNUSED, +remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server, virNetServerClientPtr cli= ent, - virNetMessagePtr msg ATTR= IBUTE_UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rer= r ATTRIBUTE_UNUSED, remote_connect_storage_po= ol_event_register_any_args *args, remote_connect_storage_po= ol_event_register_any_ret *ret) @@ -5868,12 +5904,18 @@ remoteDispatchConnectStoragePoolEventRegisterAny(vi= rNetServerPtr server ATTRIBUT struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virStoragePoolPtr pool =3D NULL; + virNetServerProgramPtr program; =20 if (!priv->storageConn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + virMutexLock(&priv->lock); =20 if (args->pool && @@ -5895,7 +5937,7 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virN= etServerPtr server ATTRIBUT 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; @@ -5976,9 +6018,9 @@ remoteDispatchConnectStoragePoolEventDeregisterAny(vi= rNetServerPtr server ATTRIB } =20 static int -remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server ATT= RIBUTE_UNUSED, +remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server, virNetServerClientPtr clie= nt, - virNetMessagePtr msg ATTRI= BUTE_UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr= ATTRIBUTE_UNUSED, remote_connect_node_device= _event_register_any_args *args, remote_connect_node_device= _event_register_any_ret *ret) @@ -5990,12 +6032,18 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(vir= NetServerPtr server ATTRIBUTE struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virNodeDevicePtr dev =3D NULL; + virNetServerProgramPtr program; =20 if (!priv->nodedevConn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + virMutexLock(&priv->lock); =20 if (args->dev && @@ -6017,7 +6065,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNe= tServerPtr server ATTRIBUTE 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; @@ -6098,9 +6146,9 @@ remoteDispatchConnectNodeDeviceEventDeregisterAny(vir= NetServerPtr server ATTRIBU } =20 static int -remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server ATTRIBU= TE_UNUSED, +remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg ATTRIBUTE= _UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr ATT= RIBUTE_UNUSED, remote_connect_secret_event_re= gister_any_args *args, remote_connect_secret_event_re= gister_any_ret *ret) @@ -6112,12 +6160,18 @@ remoteDispatchConnectSecretEventRegisterAny(virNetS= erverPtr server ATTRIBUTE_UNU struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(client); virSecretPtr secret =3D NULL; + virNetServerProgramPtr program; =20 if (!priv->secretConn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + virMutexLock(&priv->lock); =20 if (args->secret && @@ -6139,7 +6193,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetSer= verPtr server ATTRIBUTE_UNU 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; @@ -6220,9 +6274,9 @@ remoteDispatchConnectSecretEventDeregisterAny(virNetS= erverPtr server ATTRIBUTE_U } =20 static int -qemuDispatchConnectDomainMonitorEventRegister(virNetServerPtr server ATTRI= BUTE_UNUSED, +qemuDispatchConnectDomainMonitorEventRegister(virNetServerPtr server, virNetServerClientPtr client, - virNetMessagePtr msg ATTRIBU= TE_UNUSED, + virNetMessagePtr msg, virNetMessageErrorPtr rerr A= TTRIBUTE_UNUSED, qemu_connect_domain_monitor_= event_register_args *args, qemu_connect_domain_monitor_= event_register_ret *ret) @@ -6235,12 +6289,18 @@ qemuDispatchConnectDomainMonitorEventRegister(virNe= tServerPtr server ATTRIBUTE_U virNetServerClientGetPrivateData(client); virDomainPtr dom =3D NULL; const char *event =3D args->event ? *args->event : NULL; + virNetServerProgramPtr program; =20 if (!priv->conn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); goto cleanup; } =20 + if (!(program =3D virNetServerGetProgram(server, msg))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching progra= m found")); + goto cleanup; + } + virMutexLock(&priv->lock); =20 if (args->dom && @@ -6256,7 +6316,7 @@ qemuDispatchConnectDomainMonitorEventRegister(virNetS= erverPtr server ATTRIBUTE_U 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 b8b83b6b40d3..ad442182d3c8 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -1039,6 +1039,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 { @@ -1081,6 +1082,11 @@ elsif ($mode eq "server") { print " if (!(st =3D virStreamNew($conn, VIR_STREAM_NONBLOC= K)))\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 ef214980b297..47ce88392b24 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -205,6 +205,29 @@ virNetServerGetProgramLocked(virNetServerPtr srv, } =20 =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, void *opaque) diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h index a79c39fdb2e7..1867e46664ba 100644 --- a/src/rpc/virnetserver.h +++ b/src/rpc/virnetserver.h @@ -76,6 +76,8 @@ int virNetServerSetTLSContext(virNetServerPtr srv, virNetTLSContextPtr tls); # endif =20 +virNetServerProgramPtr virNetServerGetProgram(virNetServerPtr srv, + virNetMessagePtr msg); =20 int virNetServerAddClient(virNetServerPtr srv, virNetServerClientPtr client); --=20 2.13.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list