diff mbox

make qemu.log name unique

Message ID 4C2C81CD.3010504@st.com
State New
Headers show

Commit Message

Christophe Lyon July 1, 2010, 11:53 a.m. UTC
> Maybe adding a -logfile option would allow what you're trying to achieve
> without affecting other use cases? I've always thought that it's strange
> that you can only change the logfile location in the monitor and not on
> the command line.
>
> Kevin
>

Here is patch that does what you suggest.

Christophe.

Comments

Stefan Weil July 1, 2010, 1:18 p.m. UTC | #1
Am 01.07.2010 13:53, schrieb Christophe LYON:
>
>> Maybe adding a -logfile option would allow what you're trying to achieve
>> without affecting other use cases? I've always thought that it's strange
>> that you can only change the logfile location in the monitor and not on
>> the command line.
>>
>> Kevin
>>
>
> Here is patch that does what you suggest.
>
> Christophe.

Patches need a "Signed-off-by", and for the code review
it's better to send them inline.

What about patching the documentation, too?

Regards
Stefan
diff mbox

Patch

 linux-user/main.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index a6af2a5..8d1db46 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -34,7 +34,8 @@ 
 
 #include "envlist.h"
 
-#define DEBUG_LOGFILE "/tmp/qemu.log"
+#define DEFAULTDEBUG_LOGFILE "/tmp/qemu.log"
+static const char *debug_logfile = DEFAULTDEBUG_LOGFILE;
 
 char *exec_path;
 
@@ -2454,7 +2455,8 @@  static void usage(void)
 #endif
            "\n"
            "Debug options:\n"
-           "-d options   activate log (logfile=%s)\n"
+           "-d options   activate logfile\n"
+           "-logfile filename  set log file name to 'filename' (default %s)\n"
            "-p pagesize  set the host page size to 'pagesize'\n"
            "-singlestep  always run in singlestep mode\n"
            "-strace      log system calls\n"
@@ -2472,7 +2474,7 @@  static void usage(void)
            TARGET_ARCH,
            interp_prefix,
            x86_stack_size,
-           DEBUG_LOGFILE);
+           debug_logfile);
     exit(1);
 }
 
@@ -2531,15 +2533,13 @@  int main(int argc, char **argv, char **envp)
     const char *argv0 = NULL;
     int i;
     int ret;
+    int log_mask = 0;
 
     if (argc <= 1)
         usage();
 
     qemu_cache_utils_init(envp);
 
-    /* init debug */
-    cpu_set_log_filename(DEBUG_LOGFILE);
-
     if ((envlist = envlist_create()) == NULL) {
         (void) fprintf(stderr, "Unable to allocate envlist\n");
         exit(1);
@@ -2562,23 +2562,23 @@  int main(int argc, char **argv, char **envp)
         r++;
         if (!strcmp(r, "-")) {
             break;
+        } else if (!strcmp(r, "logfile")) {
+          debug_logfile = argv[optind++];
         } else if (!strcmp(r, "d")) {
-            int mask;
             const CPULogItem *item;
 
 	    if (optind >= argc)
 		break;
 
 	    r = argv[optind++];
-            mask = cpu_str_to_log_mask(r);
-            if (!mask) {
+            log_mask = cpu_str_to_log_mask(r);
+            if (!log_mask) {
                 printf("Log items (comma separated):\n");
                 for(item = cpu_log_items; item->mask != 0; item++) {
                     printf("%-10s %s\n", item->name, item->help);
                 }
                 exit(1);
             }
-            cpu_set_log(mask);
         } else if (!strcmp(r, "E")) {
             r = argv[optind++];
             if (envlist_setenv(envlist, r) != 0)
@@ -2648,6 +2648,12 @@  int main(int argc, char **argv, char **envp)
     filename = argv[optind];
     exec_path = argv[optind];
 
+    /* init debug */
+    if (log_mask) {
+      cpu_set_log_filename(debug_logfile);
+      cpu_set_log(log_mask);
+    }
+
     /* Zero out regs */
     memset(regs, 0, sizeof(struct target_pt_regs));