From nobody Sun Apr 28 16:05:25 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 1522745164225137.8471444943641; Tue, 3 Apr 2018 01:46:04 -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 B018E87620; Tue, 3 Apr 2018 08:46:02 +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 79A6717B96; Tue, 3 Apr 2018 08:46:02 +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 361931800CA0; Tue, 3 Apr 2018 08:46:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w338jv0d012053 for ; Tue, 3 Apr 2018 04:45:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 288127C45; Tue, 3 Apr 2018 08:45:57 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id A682C7C24; Tue, 3 Apr 2018 08:45:56 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:45:46 +0200 Message-Id: <75115370a7b7f919eef4f560977ab92364869268.1522744686.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 1/4] virlog: Fix a typo in virLogParseFilter's error msg 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 03 Apr 2018 08:46:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This was some copy-paste leftover. Signed-off-by: Erik Skultety --- src/util/virlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index dd927f0ba..5810643e1 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1699,7 +1699,7 @@ virLogParseFilter(const char *src) if (virStrToLong_uip(tokens[0], NULL, 10, &prio) < 0 || (prio < VIR_LOG_DEBUG) || (prio > VIR_LOG_ERROR)) { virReportError(VIR_ERR_INVALID_ARG, - _("Invalid priority '%s' for output '%s'"), + _("Invalid priority '%s' for filter '%s'"), tokens[0], src); goto cleanup; } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:05:25 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 152274516348653.115369736293246; Tue, 3 Apr 2018 01:46:03 -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 C1E0E87632; Tue, 3 Apr 2018 08:46:01 +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 86F4517A7A; Tue, 3 Apr 2018 08:46:01 +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 293DD4CA9D; Tue, 3 Apr 2018 08:46:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w338jv4c012058 for ; Tue, 3 Apr 2018 04:45:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id D704D7C28; Tue, 3 Apr 2018 08:45:57 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60CDA7C4E; Tue, 3 Apr 2018 08:45:57 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:45:47 +0200 Message-Id: <1407102c98a66f88faa0117e97ac9a23db012039.1522744686.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 2/4] libvirtd.conf: Document that we do a 'first' match on log filters 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 03 Apr 2018 08:46:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When applying the log filters, one has to define the more specific filters before the generic ones, because the first filter that matches will be applied. However, we've been missing this information in the config, so it always has been a trial-error scenario figuring out that e.g. '4:util 1:util.pci' doesn't actually enable verbose logging on the src/util/virpci.c module because 4:util will be matched first. Signed-off-by: Erik Skultety --- src/remote/libvirtd.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/remote/libvirtd.conf b/src/remote/libvirtd.conf index 4aed7e746..9c0080dc0 100644 --- a/src/remote/libvirtd.conf +++ b/src/remote/libvirtd.conf @@ -366,7 +366,9 @@ # 4: ERROR # # Multiple filters can be defined in a single @filters, they just need to = be -# separated by spaces. +# separated by spaces. Note that libvirt performs "first" match, i.e. if +# there are concurrent filters, the first one that matches will be applied, +# given the order in log_filters. # # e.g. to only get warning or errors from the remote layer and only errors # from the event layer: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:05:25 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 1522745167554289.4741415825773; Tue, 3 Apr 2018 01:46:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 408E64902F; Tue, 3 Apr 2018 08:46: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 17E0A17B3E; Tue, 3 Apr 2018 08:46:06 +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 CDB034CAA2; Tue, 3 Apr 2018 08:46:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w338jwne012074 for ; Tue, 3 Apr 2018 04:45:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 929547C45; Tue, 3 Apr 2018 08:45:58 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B9A77C49; Tue, 3 Apr 2018 08:45:57 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:45:48 +0200 Message-Id: <0480ba9343494faef036966349b001b81bb84422.1522744686.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 3/4] util: virlog: Introduce wildcard to log filters 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 03 Apr 2018 08:46:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since the introduction of log tuning capabilities to virt-admin by @06b91785, this has been a much needed missing improvement on the way to deprecate the global 'log_level'. Signed-off-by: Erik Skultety --- src/remote/libvirtd.conf | 4 +++- src/util/virlog.c | 44 +++++++++++++++++++++++++++++++++++++++++++- src/util/virlog.h | 1 + 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/remote/libvirtd.conf b/src/remote/libvirtd.conf index 9c0080dc0..7d823cf1a 100644 --- a/src/remote/libvirtd.conf +++ b/src/remote/libvirtd.conf @@ -368,7 +368,9 @@ # Multiple filters can be defined in a single @filters, they just need to = be # separated by spaces. Note that libvirt performs "first" match, i.e. if # there are concurrent filters, the first one that matches will be applied, -# given the order in log_filters. +# given the order in log_filters with the exception of a wildcard filter, = since +# that's only taken into account if no other filter has matched, so +# "4:* 1:util.pci" and "1:util.pci 4:*" are equivalent definitions. # # e.g. to only get warning or errors from the remote layer and only errors # from the event layer: diff --git a/src/util/virlog.c b/src/util/virlog.c index 5810643e1..81a9dc439 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -497,6 +497,38 @@ virLogHostnameString(char **rawmsg, return 0; } =20 +/* virLogFiltersFind: + * @filters: haystack + * @nfilters: haystack size + * @key1: primary string 'needle' + * @key2: secondary integer 'needle' + * + * Performs "first match" search on the input set of filters, using @key1 + * (string) and @key2 (integer) as primary and secondary keys respectivel= y. + * Secondary key is only considered if primary key wasn't provided. + * + * Returns a pointer to the matched object or NULL if no match was found. + */ +static virLogFilterPtr +virLogFiltersFind(virLogFilterPtr *filters, + size_t nfilters, + const char *key1, + unsigned int key2) +{ + size_t i; + + if (!key1 && key2 =3D=3D 0) + return NULL; + + for (i =3D 0; i < nfilters; i++) { + if ((key1 && STREQ(key1, filters[i]->match)) || + filters[i]->flags =3D=3D key2) + return filters[i]; + } + + return NULL; +} + =20 static void virLogSourceUpdate(virLogSourcePtr source) @@ -1409,7 +1441,8 @@ virLogFilterNew(const char *match, virLogFilterPtr ret =3D NULL; char *mdup =3D NULL; =20 - virCheckFlags(VIR_LOG_STACK_TRACE, NULL); + virCheckFlags(VIR_LOG_STACK_TRACE | + VIR_LOG_WILDCARD, NULL); =20 if (priority < VIR_LOG_DEBUG || priority > VIR_LOG_ERROR) { virReportError(VIR_ERR_INVALID_ARG, _("Invalid log priority %d"), @@ -1528,6 +1561,8 @@ virLogDefineOutputs(virLogOutputPtr *outputs, size_t = noutputs) int virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters) { + virLogFilterPtr rc; + if (virLogInitialize() < 0) return -1; =20 @@ -1535,6 +1570,10 @@ virLogDefineFilters(virLogFilterPtr *filters, size_t= nfilters) virLogResetFilters(); virLogFilters =3D filters; virLogNbFilters =3D nfilters; + + /* if there's a wildcard filter, update default priority */ + if ((rc =3D virLogFiltersFind(filters, nfilters, NULL, VIR_LOG_WILDCAR= D))) + virLogDefaultPriority =3D rc->priority; virLogUnlock(); =20 return 0; @@ -1710,6 +1749,9 @@ virLogParseFilter(const char *src) match++; } =20 + if (STREQ(match, "*")) + flags |=3D VIR_LOG_WILDCARD; + /* match string cannot comprise just from a single '+' */ if (!*match) { virReportError(VIR_ERR_INVALID_ARG, diff --git a/src/util/virlog.h b/src/util/virlog.h index 8973f83b2..07b91f0b0 100644 --- a/src/util/virlog.h +++ b/src/util/virlog.h @@ -174,6 +174,7 @@ typedef void (*virLogCloseFunc) (void *data); =20 typedef enum { VIR_LOG_STACK_TRACE =3D (1 << 0), + VIR_LOG_WILDCARD =3D (1 << 1) } virLogFlags; =20 int virLogGetNbFilters(void); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 16:05:25 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 1522745167025101.09488105698654; Tue, 3 Apr 2018 01:46:07 -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 66C738046B; Tue, 3 Apr 2018 08:46:05 +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 3879E174A8; Tue, 3 Apr 2018 08:46: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 E92564CA9F; Tue, 3 Apr 2018 08:46:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w338jxGt012079 for ; Tue, 3 Apr 2018 04:45:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4C0A77C28; Tue, 3 Apr 2018 08:45:59 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA6317C49; Tue, 3 Apr 2018 08:45:58 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Tue, 3 Apr 2018 10:45:49 +0200 Message-Id: <0870102594c7477d686062c62d9031a8bdd2bd0a.1522744686.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 4/4] news: Update the news file with the log filter wildcard improvement 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.28]); Tue, 03 Apr 2018 08:46:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Erik Skultety --- docs/news.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 87f52e83e..6dab4844d 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -47,6 +47,18 @@ supported. In fact, kernel has been supporting this since 4.10. + + + logging: Introduce wildcard to log filters + + + In an effort to deprecate the log_level variable in favour of th= e log + filters, introduce a wildcard filter, e.g. '1:*'. This change is= most + noticeable during runtime using virt-admin, where the only way to + mimic the log_level's functionality has been to specify a number= of + filters which can a bit painful. + +
--=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list