[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize |
Date: |
Thu, 11 Feb 2016 13:31:17 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 11/02/2016 13:12, Dimitris Aragiorgis wrote:
> Besides that, when one executes a daemon, shell redirection is
> hardly, if ever, used. More so if the daemon already has a logfile
> option.
>
> So, we decided to give it a go and find the least painful way to
> log the stderr of a QEMU process to a logfile.
>
> To our understanding, the logfile (-D option) is used only for
> messages generated by qemu_log()/qemu_log_mask(). The current
> situation however is that fprintf(stderr, ...) is used in various
> places throughout the codebase for logging/debug purposes.
Right, mostly through error_report.
Actually I like your approach (log to -D if daemonize is used). I
just was not sure of the best way to implement it.
Perhaps when the logfile is opened you can replace the straight fopen with
qemu_logfile = fopen(...);
if (daemonized) {
dup2(fileno(qemu_logfile), STDERR_FILENO);
fclose(qemu_logfile);
qemu_logfile = stderr;
}
Then the logfile will never be closed by qemu_log_close, and stderr
will always be sent to it. Does this look sane?
Paolo
- Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize, Paolo Bonzini, 2016/02/08
- Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize, Dimitris Aragiorgis, 2016/02/11
- Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize, Dimitris Aragiorgis, 2016/02/11
- Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize, Paolo Bonzini, 2016/02/11
- [Qemu-devel] [PATCH] log: Redirect stderr to logfile if deamonized, Dimitris Aragiorgis, 2016/02/18
- Re: [Qemu-devel] [PATCH] log: Redirect stderr to logfile if deamonized, Paolo Bonzini, 2016/02/18
- Re: [Qemu-devel] [PATCH] log: Redirect stderr to logfile if deamonized, Dimitris Aragiorgis, 2016/02/18
- Re: [Qemu-devel] [PATCH] log: Redirect stderr to logfile if deamonized, Paolo Bonzini, 2016/02/19