]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: drop support for stack traces with logging
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 2 Oct 2019 10:51:51 +0000 (11:51 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 18 Oct 2019 15:25:17 +0000 (16:25 +0100)
The log filters have supported the use of a "+" before the source match
string to request that a stack trace be emitted for every log message:

  commit 548563956e484e0e43e9a66a89bdda0f95930108
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed May 9 15:18:56 2012 +0100

    Allow stack traces to be included with log messages

    Sometimes it is useful to see the callpath for log messages.
    This change enhances the log filter syntax so that stack traces
    can be show by setting '1:+NAME' instead of '1:NAME'.

With the huge & ever increasing number of logging statements per file,
this will be incredibly verbose and have a major performance penalty.
This makes the feature impractical to use widely and as such it is not
worth the code maint cost.

Removing this seldom used feature allows us to drop the 'execinfo'
module in gnulib which provides the backtrace() function which doesn't
exist on non-Linux.

Users who want to get stack traces of parts of libvirt can use GDB,
or systemtap for live tracing with minimal perf impact.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
bootstrap.conf
docs/logging.html.in
src/locking/virtlockd.conf
src/logging/virtlogd.conf
src/remote/libvirtd.conf.in
src/util/virlog.c
tests/testutils.c
tests/virtestmock.c

index 1b5a68b873b95a2c526caf9b4b5f223a1f0c618d..0c7de2d2aa53be97515daaa0692aa31686883c1a 100644 (file)
@@ -33,7 +33,6 @@ connect
 configmake
 dirname-lgpl
 environ
-execinfo
 fclose
 fcntl
 fcntl-h
index be2fd4ab5b8e7580fddeae5447413f20d22f1d19..65c13e8a19df9f4e667cbc16785b79dd72639dac 100644 (file)
     </h2>
     <p>The syntax for filters and outputs is the same for both types of
        variables.</p>
-    <p>The format for a filter is one of:</p>
+    <p>The format for a filter is:</p>
     <pre>
-x:name  (log message only)
-x:+name (log message + stack trace)</pre>
+x:name</pre>
     <p>where <code>name</code> is a string which is matched against
     the category given in the VIR_LOG_INIT() at the top of each
     libvirt source file, e.g., <code>remote</code>, <code>qemu</code>,
     or <code>util.json</code> (the name in the filter can be a
     substring of the full category name, in order to match multiple
-    similar categories), the optional <code>+</code> prefix tells
-    libvirt to log stack trace for each message
-    matching <code>name</code>, and <code>x</code> is the minimal
+    similar categories), and <code>x</code> is the minimal
     level where matching messages should be logged:</p>
     <ul>
       <li>1: DEBUG</li>
index b65110fc3eed78a26fabc9102d23fe2fd46f75fa..152d6a844fff23e81ed495babddb0214fc54a385 100644 (file)
 
 # Logging filters:
 # A filter allows to select a different logging level for a given category
-# of logs. The format for a filter is one of:
+# of logs. The format for a filter is:
 #
 #    level:match
-#    level:+match
 #
 # where 'match' is a string which is matched against the category
 # given in the VIR_LOG_INIT() at the top of each libvirt source
@@ -35,9 +34,6 @@
 # The 'match' is always treated as a substring match. IOW a match
 # string 'foo' is equivalent to '*foo*'.
 #
-# If 'match' contains the optional "+" prefix, it tells libvirt
-# to log stack trace for each message matching name.
-#
 # 'level' is the minimal level where matching messages should
 #  be logged:
 #
index bc41edbc6b95432b700fcfc00400dec093d8a871..8b1ff0156f1e9ed297a2389c23e48f11779e6f43 100644 (file)
 
 # Logging filters:
 # A filter allows to select a different logging level for a given category
-# of logs. The format for a filter is one of:
+# of logs. The format for a filter is:
 #
 #    level:match
-#    level:+match
 #
 # where 'match' is a string which is matched against the category
 # given in the VIR_LOG_INIT() at the top of each libvirt source
@@ -35,9 +34,6 @@
 # The 'match' is always treated as a substring match. IOW a match
 # string 'foo' is equivalent to '*foo*'.
 #
-# If 'match' contains the optional "+" prefix, it tells libvirt
-# to log stack trace for each message matching name.
-#
 # 'level' is the minimal level where matching messages should
 #  be logged:
 #
index fdef97f371ee722d84e85a0f1e7339f42a3c18e1..f984ce04780ecfaaf64e2bdc0dc3b9089f6f9907 100644 (file)
 
 # Logging filters:
 # A filter allows to select a different logging level for a given category
-# of logs. The format for a filter is one of:
+# of logs. The format for a filter is:
 #
 #    level:match
-#    level:+match
 #
 # where 'match' is a string which is matched against the category
 # given in the VIR_LOG_INIT() at the top of each libvirt source
 # The 'match' is always treated as a substring match. IOW a match
 # string 'foo' is equivalent to '*foo*'.
 #
-# If 'match' contains the optional "+" prefix, it tells libvirt
-# to log stack trace for each message matching name.
-#
 # 'level' is the minimal level where matching messages should
 #  be logged:
 #
index 5881a59cc5e770dbbf43c33d9ec3dedbd376b267..2a745fca753c5c2d2c551adc66bf5a29a4c0e233 100644 (file)
@@ -28,7 +28,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <execinfo.h>
 #include <regex.h>
 #include <sys/uio.h>
 #if HAVE_SYSLOG_H
@@ -693,26 +692,6 @@ virLogVMessage(virLogSourcePtr source,
 }
 
 
-static void
-virLogStackTraceToFd(int fd)
-{
-    void *array[100];
-    int size;
-    static bool doneWarning;
-    const char *msg = "Stack trace not available on this platform\n";
-
-#define STRIP_DEPTH 3
-    size = backtrace(array, G_N_ELEMENTS(array));
-    if (size) {
-        backtrace_symbols_fd(array +  STRIP_DEPTH, size - STRIP_DEPTH, fd);
-        ignore_value(safewrite(fd, "\n", 1));
-    } else if (!doneWarning) {
-        ignore_value(safewrite(fd, msg, strlen(msg)));
-        doneWarning = true;
-    }
-#undef STRIP_DEPTH
-}
-
 static void
 virLogOutputToFd(virLogSourcePtr source G_GNUC_UNUSED,
                  virLogPriority priority G_GNUC_UNUSED,
@@ -729,6 +708,8 @@ virLogOutputToFd(virLogSourcePtr source G_GNUC_UNUSED,
     int fd = (intptr_t) data;
     char *msg;
 
+    virCheckFlags(0,);
+
     if (fd < 0)
         return;
 
@@ -737,9 +718,6 @@ virLogOutputToFd(virLogSourcePtr source G_GNUC_UNUSED,
 
     ignore_value(safewrite(fd, msg, strlen(msg)));
     VIR_FREE(msg);
-
-    if (flags & VIR_LOG_STACK_TRACE)
-        virLogStackTraceToFd(fd);
 }
 
 
@@ -832,7 +810,7 @@ virLogOutputToSyslog(virLogSourcePtr source G_GNUC_UNUSED,
                      const char *str,
                      void *data G_GNUC_UNUSED)
 {
-    virCheckFlags(VIR_LOG_STACK_TRACE,);
+    virCheckFlags(0,);
 
     syslog(virLogPrioritySyslog(priority), "%s", str);
 }
@@ -980,7 +958,7 @@ virLogOutputToJournald(virLogSourcePtr source,
                        const char *str G_GNUC_UNUSED,
                        void *data)
 {
-    virCheckFlags(VIR_LOG_STACK_TRACE,);
+    virCheckFlags(0,);
     int buffd = -1;
     int journalfd = (intptr_t) data;
     struct msghdr mh;
@@ -1168,8 +1146,6 @@ virLogGetFilters(void)
     virLogLock();
     for (i = 0; i < virLogNbFilters; i++) {
         const char *sep = ":";
-        if (virLogFilters[i]->flags & VIR_LOG_STACK_TRACE)
-            sep = ":+";
         virBufferAsprintf(&filterbuf, "%d%s%s ",
                           virLogFilters[i]->priority,
                           sep,
@@ -1416,7 +1392,7 @@ virLogFilterNew(const char *match,
     char *mdup = NULL;
     size_t mlen = strlen(match);
 
-    virCheckFlags(VIR_LOG_STACK_TRACE, NULL);
+    virCheckFlags(0, NULL);
 
     if (priority < VIR_LOG_DEBUG || priority > VIR_LOG_ERROR) {
         virReportError(VIR_ERR_INVALID_ARG, _("Invalid log priority %d"),
@@ -1659,11 +1635,8 @@ virLogParseOutput(const char *src)
  * virLogParseFilter:
  * @src: string defining a single filter
  *
- * The format of @src should be one of the following:
+ * The format of @src should be:
  *    x:name - filter affecting all modules which match 'name'
- *    x:+name
- *
- *      '+' - hints the logger to also include a stack trace for every message
  *      'name' - match string which either matches a name of a directory in
  *               libvirt's source tree which in turn affects all modules in
  *               that directory or it can matches a specific module within a
@@ -1711,7 +1684,9 @@ virLogParseFilter(const char *src)
 
     match = tokens[1];
     if (match[0] == '+') {
-        flags |= VIR_LOG_STACK_TRACE;
+        /* '+' used to indicate printing a stack trace,
+         * but we dropped that feature, so just chomp
+         * that leading '+' */
         match++;
     }
 
index 287567ab73ad191820ae754d182c2c64ea4c11e8..3a8e3142b4acd967ffaf7d80d06697af121e2bc8 100644 (file)
@@ -746,7 +746,7 @@ virtTestLogOutput(virLogSourcePtr source G_GNUC_UNUSED,
                   void *data)
 {
     struct virtTestLogData *log = data;
-    virCheckFlags(VIR_LOG_STACK_TRACE,);
+    virCheckFlags(0,);
     virBufferAsprintf(&log->buf, "%s: %s", timestamp, str);
 }
 
index daae8ef41b67943e203f97fcd3b5c6405fa1050a..9fe774836b96705d336d766e69aca09095419b66 100644 (file)
@@ -22,7 +22,6 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <fcntl.h>
-#include <execinfo.h>
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/socket.h>