mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
qemu-log: default to stderr for logging output
Switch the default for qemu_log logging output from "/tmp/qemu.log" to stderr. This is an incompatible change in some sense, but logging is mostly used for debugging purposes so it shouldn't affect production use. The previous behaviour can be obtained by adding "-D /tmp/qemu.log" to the command line. This change requires us to: * update all the documentation/help text (we take the opportunity to smooth out minor inconsistencies between the phrasing in linux-user/bsd-user/system help messages) * make linux-user and bsd-user defer to qemu-log for the default logging destination rather than overriding it themselves * ensure that all logfile closing is done via qemu_log_close() and that that function doesn't close stderr as well as the obvious change to the behaviour of do_qemu_set_log() when no logfile name has been specified. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 1361901160-28729-1-git-send-email-peter.maydell@linaro.org Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
ab4004495c
commit
989b697ddd
8 changed files with 42 additions and 53 deletions
29
qemu-log.c
29
qemu-log.c
|
@ -20,12 +20,6 @@
|
|||
#include "qemu-common.h"
|
||||
#include "qemu/log.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define DEFAULT_LOGFILENAME "qemu.log"
|
||||
#else
|
||||
#define DEFAULT_LOGFILENAME "/tmp/qemu.log"
|
||||
#endif
|
||||
|
||||
static char *logfilename;
|
||||
FILE *qemu_logfile;
|
||||
int qemu_loglevel;
|
||||
|
@ -56,14 +50,17 @@ void qemu_log_mask(int mask, const char *fmt, ...)
|
|||
/* enable or disable low levels log */
|
||||
void do_qemu_set_log(int log_flags, bool use_own_buffers)
|
||||
{
|
||||
const char *fname = logfilename ?: DEFAULT_LOGFILENAME;
|
||||
|
||||
qemu_loglevel = log_flags;
|
||||
if (qemu_loglevel && !qemu_logfile) {
|
||||
qemu_logfile = fopen(fname, log_append ? "a" : "w");
|
||||
if (!qemu_logfile) {
|
||||
perror(fname);
|
||||
_exit(1);
|
||||
if (logfilename) {
|
||||
qemu_logfile = fopen(logfilename, log_append ? "a" : "w");
|
||||
if (!qemu_logfile) {
|
||||
perror(logfilename);
|
||||
_exit(1);
|
||||
}
|
||||
} else {
|
||||
/* Default to stderr if no log file specified */
|
||||
qemu_logfile = stderr;
|
||||
}
|
||||
/* must avoid mmap() usage of glibc by setting a buffer "by hand" */
|
||||
if (use_own_buffers) {
|
||||
|
@ -81,8 +78,7 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers)
|
|||
}
|
||||
}
|
||||
if (!qemu_loglevel && qemu_logfile) {
|
||||
fclose(qemu_logfile);
|
||||
qemu_logfile = NULL;
|
||||
qemu_log_close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,10 +86,7 @@ void qemu_set_log_filename(const char *filename)
|
|||
{
|
||||
g_free(logfilename);
|
||||
logfilename = g_strdup(filename);
|
||||
if (qemu_logfile) {
|
||||
fclose(qemu_logfile);
|
||||
qemu_logfile = NULL;
|
||||
}
|
||||
qemu_log_close();
|
||||
qemu_set_log(qemu_loglevel);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue