From nobody Thu May 2 02:00: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 1503909572009420.6300549327766; Mon, 28 Aug 2017 01:39:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D57AE4A6F4; Mon, 28 Aug 2017 08:39:29 +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 0183F60621; Mon, 28 Aug 2017 08:39:28 +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 6323A3FC73; Mon, 28 Aug 2017 08:39:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7S8dMsg003865 for ; Mon, 28 Aug 2017 04:39:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9129777D43; Mon, 28 Aug 2017 08:39:22 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9C58756D8; Mon, 28 Aug 2017 08:39:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D57AE4A6F4 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Erik Skultety To: libvir-list@redhat.com Date: Mon, 28 Aug 2017 10:39:15 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH] daemon: logging: Fix --verbose option being ignored by the daemon 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 28 Aug 2017 08:39:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit 94c465d0 refactored the logging setup phase but introduced an issue, where the daemon ignores verbose mode when there are no outputs defined and the default must be used. The problem is that the default output was determined too early, thus ignoring the potential '--verbose' option taking effect. This patch postpones the creation of the default output to the very last moment when nothing else can change. Since the default output is only created during the init phase, it's safe to leave the pointer as NULL for a while, but it will be set eventually, thus not affecting runtime. Patch also adjusts both the other daemons. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1457193 Signed-off-by: Erik Skultety --- daemon/libvirtd.c | 21 +++++++++++++-------- src/locking/lock_daemon.c | 21 +++++++++++++-------- src/logging/log_daemon.c | 21 +++++++++++++-------- src/util/virlog.c | 7 +++++++ 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 7e5d7af69..589b32192 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -615,19 +615,15 @@ daemonSetupLogging(struct daemonConfig *config, * Libvirtd's order of precedence is: * cmdline > environment > config * - * The default output is applied only if there was no setting from eit= her - * the config or the environment. Because we don't have a way to deter= mine - * if the log level has been set, we must process variables in the opp= osite + * Given the precedence, we must process the variables in the opposite * order, each one overriding the previous. */ if (config->log_level !=3D 0) virLogSetDefaultPriority(config->log_level); =20 - if (virLogSetDefaultOutput("libvirtd.log", godaemon, privileged) < 0) - return -1; - - /* In case the config is empty, the filters become empty and outputs w= ill - * be set to default + /* In case the config is empty, both filters and outputs will become e= mpty, + * however we can't start with empty outputs, thus we'll need to defin= e and + * setup a default one. */ ignore_value(virLogSetFilters(config->log_filters)); ignore_value(virLogSetOutputs(config->log_outputs)); @@ -641,6 +637,15 @@ daemonSetupLogging(struct daemonConfig *config, if ((verbose) && (virLogGetDefaultPriority() > VIR_LOG_INFO)) virLogSetDefaultPriority(VIR_LOG_INFO); =20 + /* Define the default output. This is only applied if there was no set= ting + * from either the config or the environment. + */ + if (virLogSetDefaultOutput("libvirtd.log", godaemon, privileged) < 0) + return -1; + + if (virLogGetNbOutputs() =3D=3D 0) + virLogSetOutputs(virLogGetDefaultOutput()); + return 0; } =20 diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 12485e966..6fbbf4b3d 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -460,19 +460,15 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr conf= ig, * Libvirtd's order of precedence is: * cmdline > environment > config * - * The default output is applied only if there was no setting from eit= her - * the config or the environment. Because we don't have a way to deter= mine - * if the log level has been set, we must process variables in the opp= osite + * Given the precedence, we must process the variables in the opposite * order, each one overriding the previous. */ if (config->log_level !=3D 0) virLogSetDefaultPriority(config->log_level); =20 - if (virLogSetDefaultOutput("virtlockd.log", godaemon, privileged) < 0) - return -1; - - /* In case the config is empty, the filters become empty and outputs w= ill - * be set to default + /* In case the config is empty, both filters and outputs will become e= mpty, + * however we can't start with empty outputs, thus we'll need to defin= e and + * setup a default one. */ ignore_value(virLogSetFilters(config->log_filters)); ignore_value(virLogSetOutputs(config->log_outputs)); @@ -486,6 +482,15 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr confi= g, if ((verbose) && (virLogGetDefaultPriority() > VIR_LOG_INFO)) virLogSetDefaultPriority(VIR_LOG_INFO); =20 + /* Define the default output. This is only applied if there was no set= ting + * from either the config or the environment. + */ + if (virLogSetDefaultOutput("virtlockd.log", godaemon, privileged) < 0) + return -1; + + if (virLogGetNbOutputs() =3D=3D 0) + virLogSetOutputs(virLogGetDefaultOutput()); + return 0; } =20 diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index d878efa63..5a136c59d 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -388,19 +388,15 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config, * Libvirtd's order of precedence is: * cmdline > environment > config * - * The default output is applied only if there was no setting from eit= her - * the config or the environment. Because we don't have a way to deter= mine - * if the log level has been set, we must process variables in the opp= osite + * Given the precedence, we must process the variables in the opposite * order, each one overriding the previous. */ if (config->log_level !=3D 0) virLogSetDefaultPriority(config->log_level); =20 - if (virLogSetDefaultOutput("virtlogd.log", godaemon, privileged) < 0) - return -1; - - /* In case the config is empty, the filters become empty and outputs w= ill - * be set to default + /* In case the config is empty, both filters and outputs will become e= mpty, + * however we can't start with empty outputs, thus we'll need to defin= e and + * setup a default one. */ ignore_value(virLogSetFilters(config->log_filters)); ignore_value(virLogSetOutputs(config->log_outputs)); @@ -414,6 +410,15 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config, if ((verbose) && (virLogGetDefaultPriority() > VIR_LOG_INFO)) virLogSetDefaultPriority(VIR_LOG_INFO); =20 + /* Define the default output. This is only applied if there was no set= ting + * from either the config or the environment. + */ + if (virLogSetDefaultOutput("virtlogd.log", godaemon, privileged) < 0) + return -1; + + if (virLogGetNbOutputs() =3D=3D 0) + virLogSetOutputs(virLogGetDefaultOutput()); + return 0; } =20 diff --git a/src/util/virlog.c b/src/util/virlog.c index 2228cf645..d45a451a7 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1840,6 +1840,13 @@ virLogSetOutputs(const char *src) if (src && *src) outputstr =3D src; =20 + /* This can only happen during daemon init when the default output is = not + * determined yet. It's safe to do, since it's the only place setting = the + * default output. + */ + if (!outputstr) + return 0; + if ((noutputs =3D virLogParseOutputs(outputstr, &outputs)) < 0) goto cleanup; =20 --=20 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list