qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] make qemu.log name unique
@ 2010-06-29  8:46 Christophe LYON
  2010-06-29  8:59 ` Kevin Wolf
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe LYON @ 2010-06-29  8:46 UTC (permalink / raw)
  To: qemu-devel

Hello,

I propose this small patch so that the qemu log file has a unique name, 
to help running several QEmu processes at once (or with different users).

Is it OK?

Thanks

Christophe.

diff --git a/exec.c b/exec.c
index 5969eb2..5ba8d7e 100644
--- a/exec.c
+++ b/exec.c
@@ -1516,7 +1516,10 @@ void cpu_set_log(int log_flags)

  void cpu_set_log_filename(const char *filename)
  {
-    logfilename = strdup(filename);
+    /* Assume 10 chars is enough to hold pid */
+    int len = strlen(filename) + 10 + 1;
+    logfilename = malloc(len);
+    sprintf((char*)logfilename, "%s.%d", filename, getpid());
      if (logfile) {
          fclose(logfile);
          logfile = NULL;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] make qemu.log name unique
  2010-06-29  8:46 [Qemu-devel] [PATCH] make qemu.log name unique Christophe LYON
@ 2010-06-29  8:59 ` Kevin Wolf
  2010-07-01 11:53   ` Christophe LYON
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Wolf @ 2010-06-29  8:59 UTC (permalink / raw)
  To: Christophe LYON; +Cc: qemu-devel

Am 29.06.2010 10:46, schrieb Christophe LYON:
> Hello,
> 
> I propose this small patch so that the qemu log file has a unique name, 
> to help running several QEmu processes at once (or with different users).
> 
> Is it OK?

I don't think it's a good idea. When debugging things I usually run qemu
several times, and each time I'd have to look up which of all the
/tmp/qemu.log.* files is the current one instead of just refreshing the
qemu.log that I'm viewing.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] make qemu.log name unique
  2010-06-29  8:59 ` Kevin Wolf
@ 2010-07-01 11:53   ` Christophe LYON
  2010-07-01 13:18     ` Stefan Weil
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe LYON @ 2010-07-01 11:53 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel@nongnu.org

[-- Attachment #1: Type: text/plain, Size: 313 bytes --]


> 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.

[-- Attachment #2: qemu.logfile.patch --]
[-- Type: text/x-patch, Size: 2807 bytes --]

 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));
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] make qemu.log name unique
  2010-07-01 11:53   ` Christophe LYON
@ 2010-07-01 13:18     ` Stefan Weil
  2010-07-05 15:41       ` Christophe LYON
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Weil @ 2010-07-01 13:18 UTC (permalink / raw)
  To: Christophe LYON; +Cc: qemu-devel@nongnu.org

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] make qemu.log name unique
  2010-07-01 13:18     ` Stefan Weil
@ 2010-07-05 15:41       ` Christophe LYON
  0 siblings, 0 replies; 5+ messages in thread
From: Christophe LYON @ 2010-07-05 15:41 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-devel@nongnu.org


>
> Patches need a "Signed-off-by", and for the code review
> it's better to send them inline.
>
> What about patching the documentation, too?
>

OK Here is an updated version. I have also patched the bsd and darwin 
ports, but couldn't actually check it is OK for lack of such platforms.
I hope my mailer won't scramble everything.


Signed-off-by: Christophe Lyon <christophe.lyon@st.com>

  bsd-user/main.c    |   34 ++++++++++++++++++++--------------
  darwin-user/main.c |   32 +++++++++++++++++++-------------
  linux-user/main.c  |   32 +++++++++++++++++++-------------
  qemu-doc.texi      |   12 +++++++++---
  qemu-options.hx    |   11 +++++++++--
  5 files changed, 76 insertions(+), 45 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 9f8683d..8733e82 100644
--- a/bsd-user/main.c
+++ b/bsd-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;

  int singlestep;
  #if defined(CONFIG_USE_GUEST_BASE)
@@ -690,10 +691,11 @@ static void usage(void)
             "-bsd type         select emulated BSD type 
FreeBSD/NetBSD/OpenBSD (default)\n"
             "\n"
             "Debug options:\n"
-           "-d options   activate log (logfile=%s)\n"
-           "-p pagesize  set the host page size to 'pagesize'\n"
-           "-singlestep  always run in singlestep mode\n"
-           "-strace      log system calls\n"
+           "-d options         activate log\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"
             "\n"
             "Environment variables:\n"
             "QEMU_STRACE       Print system calls and arguments similar 
to the\n"
@@ -708,7 +710,7 @@ static void usage(void)
             TARGET_ARCH,
             interp_prefix,
             x86_stack_size,
-           DEBUG_LOGFILE);
+           debug_logfile);
      exit(1);
  }

@@ -741,13 +743,11 @@ int main(int argc, char **argv)
      char **target_environ, **wrk;
      envlist_t *envlist = NULL;
      bsd_type = target_openbsd;
+    int log_mask = 0;

      if (argc <= 1)
          usage();

-    /* init debug */
-    cpu_set_log_filename(DEBUG_LOGFILE);
-
      if ((envlist = envlist_create()) == NULL) {
          (void) fprintf(stderr, "Unable to allocate envlist\n");
          exit(1);
@@ -770,23 +770,23 @@ int main(int argc, char **argv)
          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) {
+	    r = argv[optind++];
+            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)
@@ -857,6 +857,12 @@ int main(int argc, char **argv)
          usage();
      filename = 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));

diff --git a/darwin-user/main.c b/darwin-user/main.c
index 5fd314e..53989c2 100644
--- a/darwin-user/main.c
+++ b/darwin-user/main.c
@@ -29,7 +29,8 @@

  #include "qemu.h"

-#define DEBUG_LOGFILE "/tmp/qemu.log"
+#define DEFAULTDEBUG_LOGFILE "/tmp/qemu.log"
+static const char *debug_logfile = DEFAULTDEBUG_LOGFILE;

  #ifdef __APPLE__
  #include <crt_externs.h>
@@ -715,15 +716,16 @@ void usage(void)
             "-s size      set the stack size in bytes (default=%ld)\n"
             "\n"
             "debug options:\n"
-           "-d options   activate log (logfile='%s')\n"
-           "-g wait for gdb on port 1234\n"
-           "-p pagesize  set the host page size to 'pagesize'\n",
-           "-singlestep  always run in singlestep mode\n"
+           "-d options         activate log\n"
+           "-logfile filename  set log file name to 'filename' (default 
%s)\n"
+           "-g                 wait for gdb on port 1234\n"
+           "-p pagesize        set the host page size to 'pagesize'\n",
+           "-singlestep        always run in singlestep mode\n"
             TARGET_ARCH,
             TARGET_ARCH,
             interp_prefix,
             stack_size,
-           DEBUG_LOGFILE);
+           debug_logfile);
      exit(1);
  }

@@ -745,13 +747,11 @@ int main(int argc, char **argv)
      short use_gdbstub = 0;
      const char *r;
      const char *cpu_model;
+    int log_mask = 0;

      if (argc <= 1)
          usage();

-    /* init debug */
-    cpu_set_log_filename(DEBUG_LOGFILE);
-
      optind = 1;
      for(;;) {
          if (optind >= argc)
@@ -763,23 +763,23 @@ int main(int argc, char **argv)
          r++;
          if (!strcmp(r, "-")) {
              break;
+        } else if (!strcmp(r, "logfile")) {
+          debug_logfile = argv[optind++];
          } else if (!strcmp(r, "d")) {
-            int mask;
              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, "s")) {
              r = argv[optind++];
              stack_size = strtol(r, (char **)&r, 0);
@@ -821,6 +821,12 @@ int main(int argc, char **argv)
          usage();
      filename = 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));

diff --git a/linux-user/main.c b/linux-user/main.c
index a6af2a5..56f78db 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,10 +2455,11 @@ static void usage(void)
  #endif
             "\n"
             "Debug options:\n"
-           "-d options   activate log (logfile=%s)\n"
-           "-p pagesize  set the host page size to 'pagesize'\n"
-           "-singlestep  always run in singlestep mode\n"
-           "-strace      log system calls\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"
             "\n"
             "Environment variables:\n"
             "QEMU_STRACE       Print system calls and arguments similar 
to the\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));

diff --git a/qemu-doc.texi b/qemu-doc.texi
index 7b8488f..cc7f322 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -2066,7 +2066,9 @@ Debug options:

  @table @option
  @item -d
-Activate log (logfile=/tmp/qemu.log)
+Activate log
+@item -logfile filename
+Set log file name to 'filename' (defaut /tmp/qemu.log)
  @item -p pagesize
  Act as if the host page size was 'pagesize' bytes
  @item -g port
@@ -2188,7 +2190,9 @@ Debug options:

  @table @option
  @item -d
-Activate log (logfile=/tmp/qemu.log)
+Activate log
+@item -logfile filename
+Set log file name to 'filename' (defaut /tmp/qemu.log)
  @item -p pagesize
  Act as if the host page size was 'pagesize' bytes
  @item -singlestep
@@ -2252,7 +2256,9 @@ Debug options:

  @table @option
  @item -d
-Activate log (logfile=/tmp/qemu.log)
+Activate log
+@item -logfile filename
+Set log file name to 'filename' (defaut /tmp/qemu.log)
  @item -p pagesize
  Act as if the host page size was 'pagesize' bytes
  @item -singlestep
diff --git a/qemu-options.hx b/qemu-options.hx
index 8de71d6..97b21d3 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1648,10 +1648,17 @@ Shorthand for -gdb tcp::1234, i.e. open a 
gdbserver on TCP port 1234
  ETEXI

  DEF("d", HAS_ARG, QEMU_OPTION_d, \
-    "-d item1,...    output log to %s (use -d ? for a list of log 
items)\n")
+    "-d item1,...    output log (use -d ? for a list of log items)\n")
  STEXI
  @item -d
-Output log in /tmp/qemu.log
+Output log
+ETEXI
+
+DEF("logfile", HAS_ARG, QEMU_OPTION_logfile, \
+    "-logfile filename\n                Set log file name to 'filename' 
(defaut %s)\n")
+STEXI
+@item -logfile
+Set log file name to 'filename' (defaut /tmp/qemu.log)
  ETEXI

  DEF("hdachs", HAS_ARG, QEMU_OPTION_hdachs, \

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-07-05 15:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-29  8:46 [Qemu-devel] [PATCH] make qemu.log name unique Christophe LYON
2010-06-29  8:59 ` Kevin Wolf
2010-07-01 11:53   ` Christophe LYON
2010-07-01 13:18     ` Stefan Weil
2010-07-05 15:41       ` Christophe LYON

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).