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