diff mbox

[2/3] trace: enable tracing in qemu-io

Message ID 1463473231-491-3-git-send-email-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev May 17, 2016, 8:20 a.m. UTC
Moving trace_init_backends() into trace_opt_parse() is not possible. This
should be called after daemonize() in vl.c.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
---
 qemu-io.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Eric Blake May 19, 2016, 11:23 p.m. UTC | #1
On 05/17/2016 02:20 AM, Denis V. Lunev wrote:
> Moving trace_init_backends() into trace_opt_parse() is not possible. This
> should be called after daemonize() in vl.c.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Kevin Wolf <kwolf@redhat.com>
> ---
>  qemu-io.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)

Please add documentation of the new syntax of the -T option, so that it
shows up in --help output (I'd ask for it in the man page, too, except
qemu-io doesn't seem to have one).

With just this patch applied, I still see in 'qemu-io --help':

  -T, --trace FILE     enable trace events listed in the given file

which doesn't tell me how to turn on particular trace events, vs. the
more useful details in 'qemu-system-x86_64 --help':

-trace [[enable=]<pattern>][,events=<file>][,file=<file>]
                specify tracing options

It is okay to just say "see qemu(1) man page for full description" (the
way we did for the --object option), rather than copy-and-paste a
paragraph that might go out of sync over time.
diff mbox

Patch

diff --git a/qemu-io.c b/qemu-io.c
index 5ef3ef7..1910fe3 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -18,6 +18,7 @@ 
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qemu/readline.h"
+#include "qemu/log.h"
 #include "qapi/qmp/qstring.h"
 #include "qom/object_interfaces.h"
 #include "sysemu/block-backend.h"
@@ -458,6 +459,7 @@  int main(int argc, char **argv)
     Error *local_error = NULL;
     QDict *opts = NULL;
     const char *format = NULL;
+    char *trace_file = NULL;
 
 #ifdef CONFIG_POSIX
     signal(SIGPIPE, SIG_IGN);
@@ -473,6 +475,7 @@  int main(int argc, char **argv)
 
     module_call_init(MODULE_INIT_QOM);
     qemu_add_opts(&qemu_object_opts);
+    qemu_add_opts(&qemu_trace_opts);
     bdrv_init();
 
     while ((c = getopt_long(argc, argv, sopt, lopt, &opt_index)) != -1) {
@@ -512,9 +515,7 @@  int main(int argc, char **argv)
             }
             break;
         case 'T':
-            if (!trace_init_backends()) {
-                exit(1); /* error message will have been printed */
-            }
+            trace_file = trace_opt_parse(optarg, trace_file);
             break;
         case 'V':
             printf("%s version %s\n", progname, QEMU_VERSION);
@@ -560,6 +561,12 @@  int main(int argc, char **argv)
         exit(1);
     }
 
+    if (!trace_init_backends()) {
+        exit(1);
+    }
+    trace_init_file(trace_file);
+    qemu_set_log(LOG_TRACE);
+
     /* initialize commands */
     qemuio_add_command(&quit_cmd);
     qemuio_add_command(&open_cmd);