summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorMatthew Fernandez <matthew.fernandez@gmail.com>2011-06-07 16:32:40 +0000
committerBlue Swirl <blauwirbel@gmail.com>2011-06-15 16:51:24 +0000
commitc235d7387c850857ec6b0ba8ee28c7e1548f68c0 (patch)
tree7ee3ca4ebda75f746d9c7ba6845b8bdab72e3f42 /vl.c
parent71f34ad05359d7fa97996562d904979281ddc7f5 (diff)
downloadqemu-c235d7387c850857ec6b0ba8ee28c7e1548f68c0.zip
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>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/vl.c b/vl.c
index c1cc614666..7b83c43e73 100644
--- a/vl.c
+++ b/vl.c
@@ -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");
}