On Tue, Jan 12, 2010 at 03:54:39PM -0500, Cole Robinson wrote:
On 01/12/2010 03:46 PM, Daniel P. Berrange wrote:
> On Tue, Jan 12, 2010 at 03:26:26PM -0500, Cole Robinson wrote:
>> 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/...
>>
>> Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
>> ---
>> src/util/util.c | 6 ++++++
>> 1 files changed, 6 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/util/util.c b/src/util/util.c
>> index 44a4b2f..23d781d 100644
>> --- a/src/util/util.c
>> +++ b/src/util/util.c
>> @@ -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,11 @@ __virExec(virConnectPtr conn,
>> of being seen / logged */
>> virSetErrorFunc(NULL, NULL);
>>
>> + /* Make sure any hook logging is sent to stderr */
>> + logprio = virLogGetDefaultPriority();
>> + virLogReset();
>> + virLogSetDefaultPriority(logprio);
>> +
>
> I'm not sure that I understand this - surely the child process is already
> inheriting this setup from the parent libvirtd ?
>
> Daniel
Problem is that virExec closes only the file descriptors it is using,
which means it will close the file descriptors for any nontrivial
logging handlers. I could add some internal logging API to get the
relevant fds and keep them from being closed, but not sure if we
necessarily want to preserve those for a daemonized process?
Oh of course - can you put a comment to that effect in your patch as a
reminder. ACK to the patch
Daniel
--
|: 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 :|