Command line support for altering the log file location

Add command line support for logging to a location other than /tmp/qemu.log.

With logging enabled (command line option -d), the log is written to
the hard-coded path /tmp/qemu.log. This patch adds support for writing
the log to a different location by passing the -D option.

Signed-off-by: Matthew Fernandez <matthew.fernandez@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Matthew Fernandez 2011-06-07 16:32:40 +00:00 committed by Blue Swirl
parent 71f34ad053
commit c235d7387c
7 changed files with 114 additions and 54 deletions

19
vl.c
View file

@ -2067,6 +2067,8 @@ int main(int argc, char **argv, char **envp)
#endif
int defconfig = 1;
const char *trace_file = NULL;
const char *log_mask = NULL;
const char *log_file = NULL;
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
@ -2441,7 +2443,10 @@ int main(int argc, char **argv, char **envp)
break;
#endif
case QEMU_OPTION_d:
set_cpu_log(optarg);
log_mask = optarg;
break;
case QEMU_OPTION_D:
log_file = optarg;
break;
case QEMU_OPTION_s:
gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT;
@ -2907,6 +2912,18 @@ int main(int argc, char **argv, char **envp)
}
loc_set_none();
/* Open the logfile at this point, if necessary. We can't open the logfile
* when encountering either of the logging options (-d or -D) because the
* other one may be encountered later on the command line, changing the
* location or level of logging.
*/
if (log_mask) {
if (log_file) {
set_cpu_log_filename(log_file);
}
set_cpu_log(log_mask);
}
if (!st_init(trace_file)) {
fprintf(stderr, "warning: unable to initialize simple trace backend\n");
}