]> xenbits.xensource.com Git - libvirt.git/commitdiff
Ensure virExec preserves logging environment
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 18 Nov 2010 13:05:19 +0000 (13:05 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 23 Nov 2010 14:09:46 +0000 (14:09 +0000)
The virFork call resets all logging handlers that may have been
set. Re-enable them after fork in virExec, so that env variables
fir LIBVIRT_LOG_OUTPUTS and LIBVIRT_LOG_FILTERS take effect
until the execve()

* src/util/util.c: Preserve logging in child in virExec

src/util/util.c

index f2fe58a8488f908cd861b01260d87839f455b1d7..a0849e1a377d50a266fbee43d3600e75f3edce6f 100644 (file)
@@ -602,6 +602,9 @@ __virExec(const char *const*argv,
         childout = -1;
     }
 
+    /* Initialize full logging for a while */
+    virLogSetFromEnv();
+
     /* Daemonize as late as possible, so the parent process can detect
      * the above errors with wait* */
     if (flags & VIR_EXEC_DAEMON) {
@@ -650,6 +653,9 @@ __virExec(const char *const*argv,
         virClearCapabilities() < 0)
         goto fork_error;
 
+    /* Close logging again to ensure no FDs leak to child */
+    virLogReset();
+
     if (envp)
         execve(argv[0], (char **) argv, (char**)envp);
     else