All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: stefanha@redhat.com, "Denis V. Lunev" <den@openvz.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH 7/7] trace: enable tracing in qemu-img
Date: Fri, 17 Jun 2016 17:44:14 +0300	[thread overview]
Message-ID: <1466174654-30130-8-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1466174654-30130-1-git-send-email-den@openvz.org>

The command will work this way:
    qemu-img --trace qcow2* create -f qcow2 1.img 64G

Signed-off-by: Denis V. Lunev <den@openvz.org>
Suggested by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
---
 Makefile      |  2 +-
 qemu-img.c    | 19 ++++++++++++++++++-
 qemu-img.texi |  3 +++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index f9d369b..2b00a37 100644
--- a/Makefile
+++ b/Makefile
@@ -566,7 +566,7 @@ qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
 	  "  GEN   $@")
 qemu.1: qemu-option-trace.texi
 
-qemu-img.1: qemu-img.texi qemu-img-cmds.texi
+qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi
 	$(call quiet-command, \
 	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-img.pod && \
 	  $(POD2MAN) --section=1 --center=" " --release=" " qemu-img.pod > $@, \
diff --git a/qemu-img.c b/qemu-img.c
index 2194c2d..3322a1e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -32,6 +32,7 @@
 #include "qemu/config-file.h"
 #include "qemu/option.h"
 #include "qemu/error-report.h"
+#include "qemu/log.h"
 #include "qom/object_interfaces.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/block-backend.h"
@@ -39,6 +40,7 @@
 #include "block/blockjob.h"
 #include "block/qapi.h"
 #include "crypto/init.h"
+#include "trace/control.h"
 #include <getopt.h>
 
 #define QEMU_IMG_VERSION "qemu-img version " QEMU_VERSION QEMU_PKGVERSION \
@@ -96,6 +98,8 @@ static void QEMU_NORETURN help(void)
            "\n"
            "    '-h', '--help'       display this help and exit\n"
            "    '-V', '--version'    output version information and exit\n"
+           "    '-T', '--trace'      [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
+           "                         specify tracing options\n"
            "\n"
            "Command syntax:\n"
 #define DEF(option, callback, arg_string)        \
@@ -3806,10 +3810,12 @@ int main(int argc, char **argv)
     const img_cmd_t *cmd;
     const char *cmdname;
     Error *local_error = NULL;
+    char *trace_file = NULL;
     int c;
     static const struct option long_options[] = {
         {"help", no_argument, 0, 'h'},
         {"version", no_argument, 0, 'V'},
+        {"trace", required_argument, NULL, 'T'},
         {0, 0, 0, 0}
     };
 
@@ -3835,8 +3841,9 @@ int main(int argc, char **argv)
 
     qemu_add_opts(&qemu_object_opts);
     qemu_add_opts(&qemu_source_opts);
+    qemu_add_opts(&qemu_trace_opts);
 
-    while ((c = getopt_long(argc, argv, "+hV", long_options, NULL)) != -1) {
+    while ((c = getopt_long(argc, argv, "+hVT:", long_options, NULL)) != -1) {
         switch (c) {
         case 'h':
             help();
@@ -3844,6 +3851,10 @@ int main(int argc, char **argv)
         case 'V':
             printf(QEMU_IMG_VERSION);
             return 0;
+        case 'T':
+            g_free(trace_file);
+            trace_file = trace_opt_parse(optarg);
+            break;
         }
     }
 
@@ -3857,6 +3868,12 @@ int main(int argc, char **argv)
     argv += optind;
     optind = 1;
 
+    if (!trace_init_backends()) {
+        exit(1);
+    }
+    trace_init_file(trace_file);
+    qemu_set_log(LOG_TRACE);
+
     /* find the command */
     for (cmd = img_cmds; cmd->name != NULL; cmd++) {
         if (!strcmp(cmdname, cmd->name)) {
diff --git a/qemu-img.texi b/qemu-img.texi
index f1b874d..449a19c 100644
--- a/qemu-img.texi
+++ b/qemu-img.texi
@@ -22,6 +22,9 @@ Standard options:
 Display this help and exit
 @item -V, --version
 Display version information and exit
+@item -T, --trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
+@findex --trace
+@include qemu-option-trace.texi
 @end table
 
 The following commands are supported:
-- 
2.1.4

  parent reply	other threads:[~2016-06-17 14:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 14:44 [Qemu-devel] [PATCH v9 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-17 14:44 ` [Qemu-devel] [PATCH 1/7] doc: sync help descriprion for --trace with man for qemu.1 Denis V. Lunev
2016-06-20 16:24   ` Eric Blake
2016-06-17 14:44 ` [Qemu-devel] [PATCH 2/7] doc: move text describing --trace to specific .texi file Denis V. Lunev
2016-06-17 14:44 ` [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c Denis V. Lunev
2016-06-17 14:44 ` [Qemu-devel] [PATCH 4/7] trace: enable tracing in qemu-io Denis V. Lunev
2016-06-17 14:44 ` [Qemu-devel] [PATCH 5/7] trace: enable tracing in qemu-nbd Denis V. Lunev
2016-06-17 14:44 ` [Qemu-devel] [PATCH 6/7] qemu-img: move common options parsing before commands processing Denis V. Lunev
2016-06-17 14:44 ` Denis V. Lunev [this message]
2016-06-20 16:26   ` [Qemu-devel] [PATCH 7/7] trace: enable tracing in qemu-img Eric Blake
2016-06-21 11:55 ` [Qemu-devel] [PATCH v9 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-22 10:20 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-22 13:17 ` [Qemu-devel] " Denis V. Lunev
2016-06-22 13:34 ` Denis V. Lunev
  -- strict thread matches above, loose matches on Subject: below --
2016-06-17 13:48 [Qemu-devel] [PATCH v8 " Denis V. Lunev
2016-06-17 13:48 ` [Qemu-devel] [PATCH 7/7] trace: enable tracing in qemu-img Denis V. Lunev
2016-06-16  7:15 [Qemu-devel] [PATCH v7 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-16  7:15 ` [Qemu-devel] [PATCH 7/7] trace: enable tracing in qemu-img Denis V. Lunev
2016-06-17 13:55   ` Stefan Hajnoczi
2016-06-14 10:08 [Qemu-devel] [PATCH v6 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-14 10:08 ` [Qemu-devel] [PATCH 7/7] trace: enable tracing in qemu-img Denis V. Lunev
2016-06-14 21:51   ` Eric Blake
2016-06-14  9:16 [Qemu-devel] [PATCH v5 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-14  9:17 ` [Qemu-devel] [PATCH 7/7] trace: enable tracing in qemu-img Denis V. Lunev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466174654-30130-8-git-send-email-den@openvz.org \
    --to=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.