[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] PATCH: Fix libvirt log initialization to not override environment



Witht he libvirtd daemon, if you start it up with LIBVIRT_LOG_OUTPUTS  or 
LIBVIRT_LOG_FILTERS set, then it'll initially use these settings for
logging, but then when it reads the config file it'll reset all logging
and ignore your environment variables. This is rather confusing ! This
quick fix makes it honour this env variables, if the config file has not
got explicit overrides.

Daniel

diff --git a/qemud/qemud.c b/qemud/qemud.c
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -2482,6 +2482,11 @@ qemudSetLogging(virConfPtr conf, const c
 
     /* there is no default filters */
     GET_CONF_STR (conf, filename, log_filters);
+    if (!log_filters) {
+        debugEnv = getenv("LIBVIRT_LOG_FILTERS");
+        if (debugEnv)
+            log_filters = strdup(debugEnv);
+    }
     virLogParseFilters(log_filters);
 
     /*
@@ -2489,7 +2494,12 @@ qemudSetLogging(virConfPtr conf, const c
      * all logs to stderr if not running as daemon
      */
     GET_CONF_STR (conf, filename, log_outputs);
-    if (log_outputs == NULL) {
+    if (!log_outputs) {
+        debugEnv = getenv("LIBVIRT_LOG_OUTPUTS");
+        if (debugEnv)
+            log_outputs = strdup(debugEnv);
+    }
+    if (!log_outputs) {
         if (godaemon) {
             char *tmp = NULL;
             if (virAsprintf (&tmp, "%d:syslog:libvirtd", log_level) < 0)
@@ -2499,8 +2509,9 @@ qemudSetLogging(virConfPtr conf, const c
         } else {
             virLogParseOutputs("0:stderr:libvirtd");
         }
-    } else
+    } else {
         virLogParseOutputs(log_outputs);
+    }
     ret = 0;
 
 free_and_fail:

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]