From nobody Sat May 4 17:48:21 2024 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 1510666867861234.6159141968502; Tue, 14 Nov 2017 05:41:07 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 0907413AAC; Tue, 14 Nov 2017 13:41:06 +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 8D2BE88E3B; Tue, 14 Nov 2017 13:41:05 +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 7F5FE4BB79; Tue, 14 Nov 2017 13:41:04 +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 vAEDf2gC000804 for ; Tue, 14 Nov 2017 08:41:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6DD8C8B55C; Tue, 14 Nov 2017 13:41:02 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id A39B35C482; Tue, 14 Nov 2017 13:41:01 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Tue, 14 Nov 2017 14:40:48 +0100 Message-Id: <3da94e71808a95c707bd568da68dca18cc2c0f38.1510666700.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 1/2] daemon: virtlogd: Drop the server shortcut ref pointer 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 14 Nov 2017 13:41:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We put the server into a hash table as we do with the other daemons, there is no compelling reason why it should have another pointer dedicated just to the server. Besides, the locking daemon doesn't have it and virtlogd is essentially a copy paste of virtlockd. Signed-off-by: Erik Skultety --- src/logging/log_daemon.c | 54 ++++++++++++++++++++++++++++----------------= ---- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 5a136c59d..7e8c9cfc2 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -59,7 +59,6 @@ VIR_LOG_INIT("logging.log_daemon"); struct _virLogDaemon { virMutex lock; virNetDaemonPtr dmn; - virNetServerPtr srv; virLogHandlerPtr handler; }; =20 @@ -117,7 +116,6 @@ virLogDaemonFree(virLogDaemonPtr logd) =20 virObjectUnref(logd->handler); virMutexDestroy(&logd->lock); - virObjectUnref(logd->srv); virObjectUnref(logd->dmn); =20 VIR_FREE(logd); @@ -139,6 +137,7 @@ static virLogDaemonPtr virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged) { virLogDaemonPtr logd; + virNetServerPtr srv; =20 if (VIR_ALLOC(logd) < 0) return NULL; @@ -150,19 +149,21 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool pr= ivileged) return NULL; } =20 - if (!(logd->srv =3D virNetServerNew("virtlogd", 1, - 1, 1, 0, config->max_clients, - config->max_clients, -1, 0, - NULL, - virLogDaemonClientNew, - virLogDaemonClientPreExecRestart, - virLogDaemonClientFree, - (void*)(intptr_t)(privileged ? 0x1 := 0x0)))) + if (!(srv =3D virNetServerNew("virtlogd", 1, + 1, 1, 0, config->max_clients, + config->max_clients, -1, 0, + NULL, + virLogDaemonClientNew, + virLogDaemonClientPreExecRestart, + virLogDaemonClientFree, + (void*)(intptr_t)(privileged ? 0x1 : 0x0))= )) goto error; =20 if (!(logd->dmn =3D virNetDaemonNew()) || - virNetDaemonAddServer(logd->dmn, logd->srv) < 0) + virNetDaemonAddServer(logd->dmn, srv) < 0) goto error; + virObjectUnref(srv); + srv =3D NULL; =20 if (!(logd->handler =3D virLogHandlerNew(privileged, config->max_size, @@ -174,6 +175,7 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool priv= ileged) return logd; =20 error: + virObjectUnref(srv); virLogDaemonFree(logd); return NULL; } @@ -191,6 +193,7 @@ virLogDaemonNewPostExecRestart(virJSONValuePtr object, = bool privileged, virLogDaemonConfigPtr config) { virLogDaemonPtr logd; + virNetServerPtr srv; virJSONValuePtr child; =20 if (VIR_ALLOC(logd) < 0) @@ -212,14 +215,15 @@ virLogDaemonNewPostExecRestart(virJSONValuePtr object= , bool privileged, if (!(logd->dmn =3D virNetDaemonNewPostExecRestart(child))) goto error; =20 - if (!(logd->srv =3D virNetDaemonAddServerPostExec(logd->dmn, - "virtlogd", - virLogDaemonClientNew, - virLogDaemonClientNewP= ostExecRestart, - virLogDaemonClientPreE= xecRestart, - virLogDaemonClientFree, - (void*)(intptr_t)(priv= ileged ? 0x1 : 0x0)))) + if (!(srv =3D virNetDaemonAddServerPostExec(logd->dmn, + "virtlogd", + virLogDaemonClientNew, + virLogDaemonClientNewPostExe= cRestart, + virLogDaemonClientPreExecRes= tart, + virLogDaemonClientFree, + (void*)(intptr_t)(privileged= ? 0x1 : 0x0)))) goto error; + virObjectUnref(srv); =20 if (!(child =3D virJSONValueObjectGet(object, "handler"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -857,6 +861,7 @@ virLogDaemonUsage(const char *argv0, bool privileged) } =20 int main(int argc, char **argv) { + virNetServerPtr srv =3D NULL; virNetServerProgramPtr logProgram =3D NULL; char *remote_config_file =3D NULL; int statuswrite =3D -1; @@ -1076,19 +1081,23 @@ int main(int argc, char **argv) { goto cleanup; } =20 - if ((rv =3D virLogDaemonSetupNetworkingSystemD(logDaemon->srv)) < = 0) { + srv =3D virNetDaemonGetServer(logDaemon->dmn, "virtlogd"); + if ((rv =3D virLogDaemonSetupNetworkingSystemD(srv)) < 0) { ret =3D VIR_LOG_DAEMON_ERR_NETWORK; goto cleanup; } =20 /* Only do this, if systemd did not pass a FD */ if (rv =3D=3D 0 && - virLogDaemonSetupNetworkingNative(logDaemon->srv, sock_file) <= 0) { + virLogDaemonSetupNetworkingNative(srv, sock_file) < 0) { ret =3D VIR_LOG_DAEMON_ERR_NETWORK; goto cleanup; } + virObjectUnref(srv); } =20 + srv =3D virNetDaemonGetServer(logDaemon->dmn, "virtlogd"); + if (timeout !=3D -1) { VIR_DEBUG("Registering shutdown timeout %d", timeout); virNetDaemonAutoShutdown(logDaemon->dmn, @@ -1107,7 +1116,7 @@ int main(int argc, char **argv) { ret =3D VIR_LOG_DAEMON_ERR_INIT; goto cleanup; } - if (virNetServerAddProgram(logDaemon->srv, logProgram) < 0) { + if (virNetServerAddProgram(srv, logProgram) < 0) { ret =3D VIR_LOG_DAEMON_ERR_INIT; goto cleanup; } @@ -1129,7 +1138,7 @@ int main(int argc, char **argv) { =20 /* Start accepting new clients from network */ =20 - virNetServerUpdateServices(logDaemon->srv, true); + virNetServerUpdateServices(srv, true); virNetDaemonRun(logDaemon->dmn); =20 if (execRestart && @@ -1142,6 +1151,7 @@ int main(int argc, char **argv) { =20 cleanup: virObjectUnref(logProgram); + virObjectUnref(srv); virLogDaemonFree(logDaemon); if (statuswrite !=3D -1) { if (ret !=3D 0) { --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 17:48:21 2024 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 1510666887477395.0884989746952; Tue, 14 Nov 2017 05:41:27 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id D80946014F; Tue, 14 Nov 2017 13:41:25 +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 A48B689D38; Tue, 14 Nov 2017 13:41:25 +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 656C51800C87; Tue, 14 Nov 2017 13:41:25 +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 vAEDf33K000811 for ; Tue, 14 Nov 2017 08:41:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A20D8B560; Tue, 14 Nov 2017 13:41:03 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC7D98B55D; Tue, 14 Nov 2017 13:41:02 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Tue, 14 Nov 2017 14:40:49 +0100 Message-Id: <8a435c10ffac327d43983c1558aad2bc93abce4d.1510666700.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 2/2] daemon: virtlockd: Call virNetDaemonGetServer regardless of post exec 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 14 Nov 2017 13:41:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We need to call it anyway, so the else branch is redundant here. Signed-off-by: Erik Skultety --- It was either this or revert the order of the conditions so that the else branch/block is actually the bigger one, complying with our guidelines. src/locking/lock_daemon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 0d5e999ef..6751b57bc 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -1325,10 +1325,11 @@ int main(int argc, char **argv) { ret =3D VIR_LOCK_DAEMON_ERR_NETWORK; goto cleanup; } - } else if (rv =3D=3D 1) { - srv =3D virNetDaemonGetServer(lockDaemon->dmn, "virtlockd"); + virObjectUnref(srv); } + srv =3D virNetDaemonGetServer(lockDaemon->dmn, "virtlockd"); + if (timeout !=3D -1) { VIR_DEBUG("Registering shutdown timeout %d", timeout); virNetDaemonAutoShutdown(lockDaemon->dmn, -- 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list