]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Remove logging handlers in virExec
authorCole Robinson <crobinso@redhat.com>
Fri, 8 Jan 2010 17:08:06 +0000 (12:08 -0500)
committerCole Robinson <crobinso@redhat.com>
Wed, 13 Jan 2010 12:02:10 +0000 (07:02 -0500)
This allows debug statements and raised errors in hook functions to
actually be logged somewhere (stderr). Users can enable debugging in the
daemon and now see more info in /var/log/libvirt/...

src/util/util.c

index 44a4b2fffb453530cd3b68a967b6b73ac6e83d8a..ba6b0dbbca354403276f0fbca916dc04b7b38a69 100644 (file)
@@ -334,6 +334,7 @@ __virExec(virConnectPtr conn,
     int pipeerr[2] = {-1,-1};
     int childout = -1;
     int childerr = -1;
+    int logprio;
     sigset_t oldmask, newmask;
     struct sigaction sig_action;
 
@@ -452,6 +453,13 @@ __virExec(virConnectPtr conn,
        of being seen / logged */
     virSetErrorFunc(NULL, NULL);
 
+    /* Make sure any hook logging is sent to stderr, since virExec will
+     * close any unknown FDs (including logging handlers) before launching
+     * the new process */
+    logprio = virLogGetDefaultPriority();
+    virLogReset();
+    virLogSetDefaultPriority(logprio);
+
     /* Clear out all signal handlers from parent so nothing
        unexpected can happen in our child once we unblock
        signals */