From nobody Sat Feb 7 09:47:34 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=1562854082; cv=none; d=zoho.com; s=zohoarc; b=hx0vyl3sx5BoUXWACsA0PNzX2prPF/uO84yicHWs3T8H3hF3hYs/n3EllhXslfy2FpcAHme3ypyUimb7FkYtfokIRgFV6ud6UitRfhlx3AE1fqnrZ3knJhjZYyDF0P2ZGDCMHZ/KSEfwYV6RIkIUrmTPwbdAv7WMpBqHi4Kzxuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562854082; 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=9DgR5JBTMP7zZhiH4/7EUsI6+gl54mdv1Mpwi9r8Wt0=; b=HgnGBcJi7knY6xBShf67Im+iwl6zNroMArKVatayKsR1lyBFdrIAojiII/iCnCq8hXP2ARBPtE9+LiAKimmMAFDT8Y06eY80mvOcPPIFJIwUqtMQp4SC0+5n2qjsiTTcPAh0yUiodeFc/EJ9Qc0bWqLid1dxvh/Nx0AyCxLl63k= 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 1562854082110523.7441413891754; Thu, 11 Jul 2019 07:08:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 805E259465; Thu, 11 Jul 2019 14:08:00 +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 55DAE60C4E; Thu, 11 Jul 2019 14:08:00 +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 0F6841833002; Thu, 11 Jul 2019 14:08:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6BE7n8V028814 for ; Thu, 11 Jul 2019 10:07:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC8A56014C; Thu, 11 Jul 2019 14:07:49 +0000 (UTC) Received: from dhcp-17-95.lcy.redhat.com (unknown [10.42.17.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5338E600CD; Thu, 11 Jul 2019 14:07:49 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 11 Jul 2019 15:07:27 +0100 Message-Id: <20190711140742.31029-5-berrange@redhat.com> In-Reply-To: <20190711140742.31029-1-berrange@redhat.com> References: <20190711140742.31029-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 04/19] rpc: allow creating RPC service from an array of FDs 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 Jul 2019 14:08:01 +0000 (UTC) The virNetServerServiceNewFD API only accepts a single FD, but it is easily changed to allow for an array of FDs to be passed in. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/libvirt_remote.syms | 2 +- src/locking/lock_daemon.c | 9 ++++-- src/logging/log_daemon.c | 9 ++++-- src/rpc/virnetserverservice.c | 53 +++++++++++++++++++++-------------- src/rpc/virnetserverservice.h | 13 +++++---- 5 files changed, 52 insertions(+), 34 deletions(-) diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index 99fe3dd07c..f05f1827f0 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -202,8 +202,8 @@ virNetServerServiceGetMaxRequests; virNetServerServiceGetPort; virNetServerServiceGetTLSContext; virNetServerServiceIsReadonly; -virNetServerServiceNewFD; virNetServerServiceNewFDOrUNIX; +virNetServerServiceNewFDs; virNetServerServiceNewPostExecRestart; virNetServerServiceNewTCP; virNetServerServiceNewUNIX; diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index bc2fb4a7fb..c10b2d383c 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -597,6 +597,7 @@ virLockDaemonSetupNetworkingSystemD(virNetServerPtr loc= kSrv, virNetServerPtr adm virNetServerServicePtr svc; char *path =3D virGetUNIXSocketPath(3 + i); virNetServerPtr srv; + int fds[] =3D { 3 + i }; =20 if (!path) return -1; @@ -616,9 +617,11 @@ virLockDaemonSetupNetworkingSystemD(virNetServerPtr lo= ckSrv, virNetServerPtr adm =20 /* Systemd passes FDs, starting immediately after stderr, * so the first FD we'll get is '3'. */ - if (!(svc =3D virNetServerServiceNewFD(3 + i, 0, - NULL, - false, 0, 1))) + if (!(svc =3D virNetServerServiceNewFDs(fds, + ARRAY_CARDINALITY(fds), + 0, + NULL, + false, 0, 1))) return -1; =20 if (virNetServerAddService(srv, svc) < 0) { diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 014596b280..6531999381 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -532,6 +532,7 @@ virLogDaemonSetupNetworkingSystemD(virNetServerPtr logS= rv, virNetServerPtr admin virNetServerServicePtr svc; char *path =3D virGetUNIXSocketPath(3 + i); virNetServerPtr srv; + int fds[] =3D { 3 + i }; =20 if (!path) return -1; @@ -551,9 +552,11 @@ virLogDaemonSetupNetworkingSystemD(virNetServerPtr log= Srv, virNetServerPtr admin =20 /* Systemd passes FDs, starting immediately after stderr, * so the first FD we'll get is '3'. */ - if (!(svc =3D virNetServerServiceNewFD(3 + i, 0, - NULL, - false, 0, 1))) + if (!(svc =3D virNetServerServiceNewFDs(fds, + ARRAY_CARDINALITY(fds), + 0, + NULL, + false, 0, 1))) return -1; =20 if (virNetServerAddService(srv, svc) < 0) { diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c index 69043ccc0e..0d2f264696 100644 --- a/src/rpc/virnetserverservice.c +++ b/src/rpc/virnetserverservice.c @@ -112,18 +112,20 @@ virNetServerServiceNewFDOrUNIX(const char *path, nrequests_client_max); =20 } else { + int fds[] =3D {(*cur_fd)++}; /* * There's still enough file descriptors. In this case we'll * use the current one and increment it afterwards. Take care * with order of operation for pointer arithmetic and auto * increment on cur_fd - the parentheses are necessary. */ - return virNetServerServiceNewFD((*cur_fd)++, - auth, - tls, - readonly, - max_queued_clients, - nrequests_client_max); + return virNetServerServiceNewFDs(fds, + ARRAY_CARDINALITY(fds), + auth, + tls, + readonly, + max_queued_clients, + nrequests_client_max); } } =20 @@ -253,30 +255,39 @@ virNetServerServicePtr virNetServerServiceNewUNIX(con= st char *path, return svc; } =20 -virNetServerServicePtr virNetServerServiceNewFD(int fd, - int auth, - virNetTLSContextPtr tls, - bool readonly, - size_t max_queued_clients, - size_t nrequests_client_ma= x) +virNetServerServicePtr virNetServerServiceNewFDs(int *fds, + size_t nfds, + int auth, + virNetTLSContextPtr tls, + bool readonly, + size_t max_queued_clients, + size_t nrequests_client_m= ax) { - virNetServerServicePtr svc; - virNetSocketPtr sock; + virNetServerServicePtr svc =3D NULL; + virNetSocketPtr *socks; + size_t i; =20 - if (virNetSocketNewListenFD(fd, - &sock) < 0) - return NULL; + if (VIR_ALLOC_N(socks, nfds) < 0) + goto cleanup; =20 - svc =3D virNetServerServiceNewSocket(&sock, - 1, + for (i =3D 0; i < nfds; i++) { + if (virNetSocketNewListenFD(fds[i], + &socks[i]) < 0) + goto cleanup; + } + + svc =3D virNetServerServiceNewSocket(socks, + nfds, auth, tls, readonly, max_queued_clients, nrequests_client_max); =20 - virObjectUnref(sock); - + cleanup: + for (i =3D 0; i < nfds && socks; i++) + virObjectUnref(socks[i]); + VIR_FREE(socks); return svc; } =20 diff --git a/src/rpc/virnetserverservice.h b/src/rpc/virnetserverservice.h index 5dd22bd929..59ee51e5ee 100644 --- a/src/rpc/virnetserverservice.h +++ b/src/rpc/virnetserverservice.h @@ -60,12 +60,13 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const= char *path, bool readonly, size_t max_queued_client= s, size_t nrequests_client_= max); -virNetServerServicePtr virNetServerServiceNewFD(int fd, - int auth, - virNetTLSContextPtr tls, - bool readonly, - size_t max_queued_clients, - size_t nrequests_client_ma= x); +virNetServerServicePtr virNetServerServiceNewFDs(int *fd, + size_t nfds, + int auth, + virNetTLSContextPtr tls, + bool readonly, + size_t max_queued_clients, + size_t nrequests_client_m= ax); =20 virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValueP= tr object); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list