qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/8] Tracing patches
@ 2016-06-28 21:27 Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 1/8] doc: sync help description for --trace with man for qemu.1 Stefan Hajnoczi
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Stefan Hajnoczi

The following changes since commit d7f30403576f04f1f3a5fb5a1d18cba8dfa7a6d2:

  cputlb: don't cpu_abort() if guest tries to execute outside RAM or RAM (2016-06-28 18:50:53 +0100)

are available in the git repository at:

  git://github.com/stefanha/qemu.git tags/tracing-pull-request

for you to fetch changes up to 9c15e70086f3343bd810c6150d92ebfd6f346fcf:

  trace: [*-user] Add events to trace guest syscalls in syscall emulation mode (2016-06-28 21:14:12 +0100)

----------------------------------------------------------------

----------------------------------------------------------------

Denis V. Lunev (7):
  doc: sync help description for --trace with man for qemu.1
  doc: move text describing --trace to specific .texi file
  trace: move qemu_trace_opts to trace/control.c
  trace: enable tracing in qemu-io
  trace: enable tracing in qemu-nbd
  qemu-img: move common options parsing before commands processing
  trace: enable tracing in qemu-img

Lluís Vilanova (1):
  trace: [*-user] Add events to trace guest syscalls in syscall
    emulation mode

 Makefile               |  7 +++---
 bsd-user/syscall.c     |  9 ++++++++
 linux-user/syscall.c   |  2 ++
 qemu-img.c             | 58 ++++++++++++++++++++++++++++++++++++++------------
 qemu-img.texi          | 13 ++++++++++-
 qemu-io.c              | 18 ++++++++++++----
 qemu-nbd.c             | 19 ++++++++++++++++-
 qemu-nbd.texi          |  3 +++
 qemu-option-trace.texi | 25 ++++++++++++++++++++++
 qemu-options.hx        | 29 ++-----------------------
 trace-events           | 16 ++++++++++++++
 trace/control.c        | 42 +++++++++++++++++++++++++++++++++++-
 trace/control.h        | 25 ++++++++++++----------
 vl.c                   | 38 ++-------------------------------
 14 files changed, 206 insertions(+), 98 deletions(-)
 create mode 100644 qemu-option-trace.texi

-- 
2.7.4

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

* [Qemu-devel] [PULL 1/8] doc: sync help description for --trace with man for qemu.1
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
@ 2016-06-28 21:27 ` Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 2/8] doc: move text describing --trace to specific .texi file Stefan Hajnoczi
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Denis V. Lunev, Paolo Bonzini, Kevin Wolf,
	Stefan Hajnoczi

From: "Denis V. Lunev" <den@openvz.org>

[s/descriprion/description/ in commit message as suggested by Eric Blake
<eblake@redhat.com>.
--Stefan]

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1466174654-30130-2-git-send-email-den@openvz.org
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 qemu-options.hx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 44c658f..ab42530 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3669,7 +3669,7 @@ DEF("trace", HAS_ARG, QEMU_OPTION_trace,
 STEXI
 HXCOMM This line is not accurate, as some sub-options are backend-specific but
 HXCOMM HX does not support conditional compilation of text.
-@item -trace [events=@var{file}][,file=@var{file}]
+@item -trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
 @findex -trace
 
 Specify tracing options.
-- 
2.7.4

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

* [Qemu-devel] [PULL 2/8] doc: move text describing --trace to specific .texi file
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 1/8] doc: sync help description for --trace with man for qemu.1 Stefan Hajnoczi
@ 2016-06-28 21:27 ` Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 3/8] trace: move qemu_trace_opts to trace/control.c Stefan Hajnoczi
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Denis V. Lunev, Paolo Bonzini, Stefan Hajnoczi,
	Kevin Wolf

From: "Denis V. Lunev" <den@openvz.org>

This text will be included to qemu-nbd/qemu-img mans in the next patches.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1466174654-30130-3-git-send-email-den@openvz.org
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 Makefile               |  3 ++-
 qemu-option-trace.texi | 25 +++++++++++++++++++++++++
 qemu-options.hx        | 27 +--------------------------
 3 files changed, 28 insertions(+), 27 deletions(-)
 create mode 100644 qemu-option-trace.texi

diff --git a/Makefile b/Makefile
index 7087fc2..b72093f 100644
--- a/Makefile
+++ b/Makefile
@@ -564,6 +564,7 @@ qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
 	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
 	  $(POD2MAN) --section=1 --center=" " --release=" " qemu.pod > $@, \
 	  "  GEN   $@")
+qemu.1: qemu-option-trace.texi
 
 qemu-img.1: qemu-img.texi qemu-img-cmds.texi
 	$(call quiet-command, \
@@ -595,7 +596,7 @@ info: qemu-doc.info qemu-tech.info
 pdf: qemu-doc.pdf qemu-tech.pdf
 
 qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
-	qemu-img.texi qemu-nbd.texi qemu-options.texi \
+	qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-option-trace.texi \
 	qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \
 	qemu-monitor-info.texi
 
diff --git a/qemu-option-trace.texi b/qemu-option-trace.texi
new file mode 100644
index 0000000..693ab5a
--- /dev/null
+++ b/qemu-option-trace.texi
@@ -0,0 +1,25 @@
+Specify tracing options.
+
+@table @option
+@item [enable=]@var{pattern}
+Immediately enable events matching @var{pattern}.
+The file must contain one event name (as listed in the @file{trace-events-all}
+file) per line; globbing patterns are accepted too.  This option is only
+available if QEMU has been compiled with the @var{simple}, @var{stderr}
+or @var{ftrace} tracing backend.  To specify multiple events or patterns,
+specify the @option{-trace} option multiple times.
+
+Use @code{-trace help} to print a list of names of trace points.
+
+@item events=@var{file}
+Immediately enable events listed in @var{file}.
+The file must contain one event name (as listed in the @file{trace-events-all}
+file) per line; globbing patterns are accepted too.  This option is only
+available if QEMU has been compiled with the @var{simple}, @var{stderr} or
+@var{ftrace} tracing backend.
+
+@item file=@var{file}
+Log output traces to @var{file}.
+This option is only available if QEMU has been compiled with
+the @var{simple} tracing backend.
+@end table
diff --git a/qemu-options.hx b/qemu-options.hx
index ab42530..a95a936 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3671,32 +3671,7 @@ HXCOMM This line is not accurate, as some sub-options are backend-specific but
 HXCOMM HX does not support conditional compilation of text.
 @item -trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
 @findex -trace
-
-Specify tracing options.
-
-@table @option
-@item [enable=]@var{pattern}
-Immediately enable events matching @var{pattern}.
-The file must contain one event name (as listed in the @file{trace-events-all}
-file) per line; globbing patterns are accepted too.  This option is only
-available if QEMU has been compiled with the @var{simple}, @var{stderr}
-or @var{ftrace} tracing backend.  To specify multiple events or patterns,
-specify the @option{-trace} option multiple times.
-
-Use @code{-trace help} to print a list of names of trace points.
-
-@item events=@var{file}
-Immediately enable events listed in @var{file}.
-The file must contain one event name (as listed in the @file{trace-events-all}
-file) per line; globbing patterns are accepted too.  This option is only
-available if QEMU has been compiled with the @var{simple}, @var{stderr} or
-@var{ftrace} tracing backend.
-
-@item file=@var{file}
-Log output traces to @var{file}.
-This option is only available if QEMU has been compiled with
-the @var{simple} tracing backend.
-@end table
+@include qemu-option-trace.texi
 ETEXI
 
 HXCOMM Internal use
-- 
2.7.4

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

* [Qemu-devel] [PULL 3/8] trace: move qemu_trace_opts to trace/control.c
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 1/8] doc: sync help description for --trace with man for qemu.1 Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 2/8] doc: move text describing --trace to specific .texi file Stefan Hajnoczi
@ 2016-06-28 21:27 ` Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 4/8] trace: enable tracing in qemu-io Stefan Hajnoczi
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Denis V. Lunev, Paolo Bonzini, Stefan Hajnoczi,
	Kevin Wolf

From: "Denis V. Lunev" <den@openvz.org>

The patch also creates trace_opt_parse() helper in trace/control.c to reuse
this code in next patches for qemu-nbd and qemu-io.

The patch also makes trace_init_events() static, as this call is not used
outside the module anymore.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1466174654-30130-4-git-send-email-den@openvz.org
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 trace/control.c | 42 +++++++++++++++++++++++++++++++++++++++++-
 trace/control.h | 25 ++++++++++++++-----------
 vl.c            | 38 ++------------------------------------
 3 files changed, 57 insertions(+), 48 deletions(-)

diff --git a/trace/control.c b/trace/control.c
index e1556a3..86de8b9 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -21,11 +21,33 @@
 #endif
 #include "qapi/error.h"
 #include "qemu/error-report.h"
+#include "qemu/config-file.h"
 #include "monitor/monitor.h"
 
 int trace_events_enabled_count;
 bool trace_events_dstate[TRACE_EVENT_COUNT];
 
+QemuOptsList qemu_trace_opts = {
+    .name = "trace",
+    .implied_opt_name = "enable",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_trace_opts.head),
+    .desc = {
+        {
+            .name = "enable",
+            .type = QEMU_OPT_STRING,
+        },
+        {
+            .name = "events",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "file",
+            .type = QEMU_OPT_STRING,
+        },
+        { /* end of list */ }
+    },
+};
+
+
 TraceEvent *trace_event_name(const char *name)
 {
     assert(name != NULL);
@@ -142,7 +164,7 @@ void trace_enable_events(const char *line_buf)
     }
 }
 
-void trace_init_events(const char *fname)
+static void trace_init_events(const char *fname)
 {
     Location loc;
     FILE *fp;
@@ -217,3 +239,21 @@ bool trace_init_backends(void)
 
     return true;
 }
+
+char *trace_opt_parse(const char *optarg)
+{
+    char *trace_file;
+    QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
+                                             optarg, true);
+    if (!opts) {
+        exit(1);
+    }
+    if (qemu_opt_get(opts, "enable")) {
+        trace_enable_events(qemu_opt_get(opts, "enable"));
+    }
+    trace_init_events(qemu_opt_get(opts, "events"));
+    trace_file = g_strdup(qemu_opt_get(opts, "file"));
+    qemu_opts_del(opts);
+
+    return trace_file;
+}
diff --git a/trace/control.h b/trace/control.h
index e2ba6d4..a2dd3ea 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -160,17 +160,6 @@ static void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
 bool trace_init_backends(void);
 
 /**
- * trace_init_events:
- * @events: Name of file with events to be enabled at startup; may be NULL.
- *          Corresponds to commandline option "-trace events=...".
- *
- * Read the list of enabled tracing events.
- *
- * Returns: Whether the backends could be successfully initialized.
- */
-void trace_init_events(const char *file);
-
-/**
  * trace_init_file:
  * @file:   Name of trace output file; may be NULL.
  *          Corresponds to commandline option "-trace file=...".
@@ -197,6 +186,20 @@ void trace_list_events(void);
  */
 void trace_enable_events(const char *line_buf);
 
+/**
+ * Definition of QEMU options describing trace subsystem configuration
+ */
+extern QemuOptsList qemu_trace_opts;
+
+/**
+ * trace_opt_parse:
+ * @optarg: A string argument of --trace command line argument
+ *
+ * Initialize tracing subsystem.
+ *
+ * Returns the filename to save trace to.  It must be freed with g_free().
+ */
+char *trace_opt_parse(const char *optarg);
 
 #include "trace/control-internal.h"
 
diff --git a/vl.c b/vl.c
index 4c1f9ae..90cf638 100644
--- a/vl.c
+++ b/vl.c
@@ -262,26 +262,6 @@ static QemuOptsList qemu_sandbox_opts = {
     },
 };
 
-static QemuOptsList qemu_trace_opts = {
-    .name = "trace",
-    .implied_opt_name = "enable",
-    .head = QTAILQ_HEAD_INITIALIZER(qemu_trace_opts.head),
-    .desc = {
-        {
-            .name = "enable",
-            .type = QEMU_OPT_STRING,
-        },
-        {
-            .name = "events",
-            .type = QEMU_OPT_STRING,
-        },{
-            .name = "file",
-            .type = QEMU_OPT_STRING,
-        },
-        { /* end of list */ }
-    },
-};
-
 static QemuOptsList qemu_option_rom_opts = {
     .name = "option-rom",
     .implied_opt_name = "romfile",
@@ -3864,23 +3844,9 @@ int main(int argc, char **argv, char **envp)
                 xen_mode = XEN_ATTACH;
                 break;
             case QEMU_OPTION_trace:
-            {
-                opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
-                                               optarg, true);
-                if (!opts) {
-                    exit(1);
-                }
-                if (qemu_opt_get(opts, "enable")) {
-                    trace_enable_events(qemu_opt_get(opts, "enable"));
-                }
-                trace_init_events(qemu_opt_get(opts, "events"));
-                if (trace_file) {
-                    g_free(trace_file);
-                }
-                trace_file = g_strdup(qemu_opt_get(opts, "file"));
-                qemu_opts_del(opts);
+                g_free(trace_file);
+                trace_file = trace_opt_parse(optarg);
                 break;
-            }
             case QEMU_OPTION_readconfig:
                 {
                     int ret = qemu_read_config_file(optarg);
-- 
2.7.4

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

* [Qemu-devel] [PULL 4/8] trace: enable tracing in qemu-io
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
                   ` (2 preceding siblings ...)
  2016-06-28 21:27 ` [Qemu-devel] [PULL 3/8] trace: move qemu_trace_opts to trace/control.c Stefan Hajnoczi
@ 2016-06-28 21:27 ` Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 5/8] trace: enable tracing in qemu-nbd Stefan Hajnoczi
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Denis V. Lunev, Paolo Bonzini, Kevin Wolf,
	Stefan Hajnoczi

From: "Denis V. Lunev" <den@openvz.org>

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>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1466174654-30130-5-git-send-email-den@openvz.org
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 qemu-io.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/qemu-io.c b/qemu-io.c
index d977a6e..db129ea 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"
@@ -253,7 +254,9 @@ static void usage(const char *name)
 "  -k, --native-aio     use kernel AIO implementation (on Linux only)\n"
 "  -t, --cache=MODE     use the given cache mode for the image\n"
 "  -d, --discard=MODE   use the given discard mode for the image\n"
-"  -T, --trace FILE     enable trace events listed in the given file\n"
+"  -T, --trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
+"                       specify tracing options\n"
+"                       see qemu-img(1) man page for full description\n"
 "  -h, --help           display this help and exit\n"
 "  -V, --version        output version information and exit\n"
 "\n"
@@ -458,6 +461,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);
@@ -470,6 +474,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) {
@@ -509,9 +514,8 @@ int main(int argc, char **argv)
             }
             break;
         case 'T':
-            if (!trace_init_backends()) {
-                exit(1); /* error message will have been printed */
-            }
+            g_free(trace_file);
+            trace_file = trace_opt_parse(optarg);
             break;
         case 'V':
             printf("%s version %s\n", progname, QEMU_VERSION);
@@ -557,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);
-- 
2.7.4

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

* [Qemu-devel] [PULL 5/8] trace: enable tracing in qemu-nbd
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
                   ` (3 preceding siblings ...)
  2016-06-28 21:27 ` [Qemu-devel] [PULL 4/8] trace: enable tracing in qemu-io Stefan Hajnoczi
@ 2016-06-28 21:27 ` Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 6/8] qemu-img: move common options parsing before commands processing Stefan Hajnoczi
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Denis V. Lunev, Paolo Bonzini, Kevin Wolf,
	Stefan Hajnoczi

From: "Denis V. Lunev" <den@openvz.org>

Please note, trace_init_backends() must be called in the final process,
i.e. after daemonization. This is necessary to keep tracing thread in
the proper process.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1466174654-30130-6-git-send-email-den@openvz.org
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 Makefile      |  2 +-
 qemu-nbd.c    | 19 ++++++++++++++++++-
 qemu-nbd.texi |  3 +++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b72093f..2d31af0 100644
--- a/Makefile
+++ b/Makefile
@@ -578,7 +578,7 @@ fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
 	  $(POD2MAN) --section=1 --center=" " --release=" " fsdev/virtfs-proxy-helper.pod > $@, \
 	  "  GEN   $@")
 
-qemu-nbd.8: qemu-nbd.texi
+qemu-nbd.8: qemu-nbd.texi qemu-option-trace.texi
 	$(call quiet-command, \
 	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-nbd.pod && \
 	  $(POD2MAN) --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 9519db3..321f02b 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -27,12 +27,14 @@
 #include "qemu/error-report.h"
 #include "qemu/config-file.h"
 #include "qemu/bswap.h"
+#include "qemu/log.h"
 #include "block/snapshot.h"
 #include "qapi/util.h"
 #include "qapi/qmp/qstring.h"
 #include "qom/object_interfaces.h"
 #include "io/channel-socket.h"
 #include "crypto/init.h"
+#include "trace/control.h"
 
 #include <getopt.h>
 #include <libgen.h>
@@ -88,6 +90,8 @@ static void usage(const char *name)
 "General purpose options:\n"
 "  --object type,id=ID,...   define an object such as 'secret' for providing\n"
 "                            passwords and/or encryption keys\n"
+"  -T, --trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
+"                            specify tracing options\n"
 #ifdef __linux__
 "Kernel NBD client support:\n"
 "  -c, --connect=DEV         connect FILE to the local NBD device DEV\n"
@@ -470,7 +474,7 @@ int main(int argc, char **argv)
     off_t fd_size;
     QemuOpts *sn_opts = NULL;
     const char *sn_id_or_name = NULL;
-    const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:x:";
+    const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:x:T:";
     struct option lopt[] = {
         { "help", no_argument, NULL, 'h' },
         { "version", no_argument, NULL, 'V' },
@@ -498,6 +502,7 @@ int main(int argc, char **argv)
         { "export-name", required_argument, NULL, 'x' },
         { "tls-creds", required_argument, NULL, QEMU_NBD_OPT_TLSCREDS },
         { "image-opts", no_argument, NULL, QEMU_NBD_OPT_IMAGE_OPTS },
+        { "trace", required_argument, NULL, 'T' },
         { NULL, 0, NULL, 0 }
     };
     int ch;
@@ -518,6 +523,7 @@ int main(int argc, char **argv)
     const char *tlscredsid = NULL;
     bool imageOpts = false;
     bool writethrough = true;
+    char *trace_file = NULL;
 
     /* The client thread uses SIGTERM to interrupt the server.  A signal
      * handler ensures that "qemu-nbd -v -c" exits with a nice status code.
@@ -531,6 +537,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);
     qemu_init_exec_dir(argv[0]);
 
     while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
@@ -703,6 +710,10 @@ int main(int argc, char **argv)
         case QEMU_NBD_OPT_IMAGE_OPTS:
             imageOpts = true;
             break;
+        case 'T':
+            g_free(trace_file);
+            trace_file = trace_opt_parse(optarg);
+            break;
         }
     }
 
@@ -718,6 +729,12 @@ int main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
 
+    if (!trace_init_backends()) {
+        exit(1);
+    }
+    trace_init_file(trace_file);
+    qemu_set_log(LOG_TRACE);
+
     if (tlscredsid) {
         if (sockpath) {
             error_report("TLS is only supported with IPv4/IPv6");
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index 9f23343..91ebf04 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -92,6 +92,9 @@ Display extra debugging information
 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
 
 @c man end
-- 
2.7.4

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

* [Qemu-devel] [PULL 6/8] qemu-img: move common options parsing before commands processing
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
                   ` (4 preceding siblings ...)
  2016-06-28 21:27 ` [Qemu-devel] [PULL 5/8] trace: enable tracing in qemu-nbd Stefan Hajnoczi
@ 2016-06-28 21:27 ` Stefan Hajnoczi
  2016-06-29  8:22   ` Denis V. Lunev
  2016-06-28 21:27 ` [Qemu-devel] [PULL 7/8] trace: enable tracing in qemu-img Stefan Hajnoczi
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Denis V. Lunev, Paolo Bonzini, Kevin Wolf,
	Stefan Hajnoczi

From: "Denis V. Lunev" <den@openvz.org>

This is necessary to enable creation of common qemu-img options which will
be specified before command.

The patch also enables '-V' alias to '--version' (exactly like in other
block utilities) and documents this change.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1466174654-30130-7-git-send-email-den@openvz.org
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 qemu-img.c    | 41 +++++++++++++++++++++++++++--------------
 qemu-img.texi | 10 +++++++++-
 2 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 14e2661..2194c2d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -91,9 +91,12 @@ static void QEMU_NORETURN help(void)
 {
     const char *help_msg =
            QEMU_IMG_VERSION
-           "usage: qemu-img command [command options]\n"
+           "usage: qemu-img [standard options] command [command options]\n"
            "QEMU disk image utility\n"
            "\n"
+           "    '-h', '--help'       display this help and exit\n"
+           "    '-V', '--version'    output version information and exit\n"
+           "\n"
            "Command syntax:\n"
 #define DEF(option, callback, arg_string)        \
            "  " arg_string "\n"
@@ -3806,7 +3809,7 @@ int main(int argc, char **argv)
     int c;
     static const struct option long_options[] = {
         {"help", no_argument, 0, 'h'},
-        {"version", no_argument, 0, 'v'},
+        {"version", no_argument, 0, 'V'},
         {0, 0, 0, 0}
     };
 
@@ -3829,28 +3832,38 @@ int main(int argc, char **argv)
     if (argc < 2) {
         error_exit("Not enough arguments");
     }
-    cmdname = argv[1];
 
     qemu_add_opts(&qemu_object_opts);
     qemu_add_opts(&qemu_source_opts);
 
+    while ((c = getopt_long(argc, argv, "+hV", long_options, NULL)) != -1) {
+        switch (c) {
+        case 'h':
+            help();
+            return 0;
+        case 'V':
+            printf(QEMU_IMG_VERSION);
+            return 0;
+        }
+    }
+
+    cmdname = argv[optind];
+
+    /* reset getopt_long scanning */
+    argc -= optind;
+    if (argc < 1) {
+        return 0;
+    }
+    argv += optind;
+    optind = 1;
+
     /* find the command */
     for (cmd = img_cmds; cmd->name != NULL; cmd++) {
         if (!strcmp(cmdname, cmd->name)) {
-            return cmd->handler(argc - 1, argv + 1);
+            return cmd->handler(argc, argv);
         }
     }
 
-    c = getopt_long(argc, argv, "h", long_options, NULL);
-
-    if (c == 'h') {
-        help();
-    }
-    if (c == 'v') {
-        printf(QEMU_IMG_VERSION);
-        return 0;
-    }
-
     /* not found */
     error_exit("Command not found: %s", cmdname);
 }
diff --git a/qemu-img.texi b/qemu-img.texi
index cbe50e9..f1b874d 100644
--- a/qemu-img.texi
+++ b/qemu-img.texi
@@ -1,6 +1,6 @@
 @example
 @c man begin SYNOPSIS
-@command{qemu-img} @var{command} [@var{command} @var{options}]
+@command{qemu-img} [@var{standard} @var{options}] @var{command} [@var{command} @var{options}]
 @c man end
 @end example
 
@@ -16,6 +16,14 @@ inconsistent state.
 
 @c man begin OPTIONS
 
+Standard options:
+@table @option
+@item -h, --help
+Display this help and exit
+@item -V, --version
+Display version information and exit
+@end table
+
 The following commands are supported:
 
 @include qemu-img-cmds.texi
-- 
2.7.4

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

* [Qemu-devel] [PULL 7/8] trace: enable tracing in qemu-img
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
                   ` (5 preceding siblings ...)
  2016-06-28 21:27 ` [Qemu-devel] [PULL 6/8] qemu-img: move common options parsing before commands processing Stefan Hajnoczi
@ 2016-06-28 21:27 ` Stefan Hajnoczi
  2016-06-28 21:27 ` [Qemu-devel] [PULL 8/8] trace: [*-user] Add events to trace guest syscalls in syscall emulation mode Stefan Hajnoczi
  2016-06-29 15:08 ` [Qemu-devel] [PULL 0/8] Tracing patches Peter Maydell
  8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Denis V. Lunev, Paolo Bonzini, Kevin Wolf,
	Stefan Hajnoczi

From: "Denis V. Lunev" <den@openvz.org>

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

[Quote "qcow2*" to protect against shell globbing as suggested by Eric
Blake <eblake@redhat.com>.
--Stefan]

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1466174654-30130-8-git-send-email-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>
Signed-off-by: Stefan Hajnoczi <stefanha@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 2d31af0..9d12dc6 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.7.4

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

* [Qemu-devel] [PULL 8/8] trace: [*-user] Add events to trace guest syscalls in syscall emulation mode
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
                   ` (6 preceding siblings ...)
  2016-06-28 21:27 ` [Qemu-devel] [PULL 7/8] trace: enable tracing in qemu-img Stefan Hajnoczi
@ 2016-06-28 21:27 ` Stefan Hajnoczi
  2016-06-29 15:08 ` [Qemu-devel] [PULL 0/8] Tracing patches Peter Maydell
  8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2016-06-28 21:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Lluís Vilanova, Stefan Hajnoczi

From: Lluís Vilanova <vilanova@ac.upc.edu>

Adds two events to trace syscalls in syscall emulation mode (*-user):

* guest_user_syscall: Emitted before the syscall is emulated; contains
  the syscall number and arguments.

* guest_user_syscall_ret: Emitted after the syscall is emulated;
  contains the syscall number and return value.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Message-id: 146651712411.12388.10024905980452504938.stgit@fimbulvetr.bsc.es
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 bsd-user/syscall.c   |  9 +++++++++
 linux-user/syscall.c |  2 ++
 trace-events         | 16 ++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index a9fe869..66492aa 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -315,12 +315,14 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
                             abi_long arg5, abi_long arg6, abi_long arg7,
                             abi_long arg8)
 {
+    CPUState *cpu = ENV_GET_CPU(cpu_env);
     abi_long ret;
     void *p;
 
 #ifdef DEBUG
     gemu_log("freebsd syscall %d\n", num);
 #endif
+    trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
     if(do_strace)
         print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
 
@@ -400,6 +402,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
     if (do_strace)
         print_freebsd_syscall_ret(num, ret);
+    trace_guest_user_syscall_ret(cpu, num, ret);
     return ret;
  efault:
     ret = -TARGET_EFAULT;
@@ -410,12 +413,14 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
                            abi_long arg2, abi_long arg3, abi_long arg4,
                            abi_long arg5, abi_long arg6)
 {
+    CPUState *cpu = ENV_GET_CPU(cpu_env);
     abi_long ret;
     void *p;
 
 #ifdef DEBUG
     gemu_log("netbsd syscall %d\n", num);
 #endif
+    trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
     if(do_strace)
         print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
 
@@ -472,6 +477,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
     if (do_strace)
         print_netbsd_syscall_ret(num, ret);
+    trace_guest_user_syscall_ret(cpu, num, ret);
     return ret;
  efault:
     ret = -TARGET_EFAULT;
@@ -482,12 +488,14 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
                             abi_long arg2, abi_long arg3, abi_long arg4,
                             abi_long arg5, abi_long arg6)
 {
+    CPUState *cpu = ENV_GET_CPU(cpu_env);
     abi_long ret;
     void *p;
 
 #ifdef DEBUG
     gemu_log("openbsd syscall %d\n", num);
 #endif
+    trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
     if(do_strace)
         print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
 
@@ -544,6 +552,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
     if (do_strace)
         print_openbsd_syscall_ret(num, ret);
+    trace_guest_user_syscall_ret(cpu, num, ret);
     return ret;
  efault:
     ret = -TARGET_EFAULT;
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1c17b74..e59f16d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6690,6 +6690,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #ifdef DEBUG
     gemu_log("syscall %d", num);
 #endif
+    trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
     if(do_strace)
         print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
 
@@ -11182,6 +11183,7 @@ fail:
 #endif
     if(do_strace)
         print_syscall_ret(num, ret);
+    trace_guest_user_syscall_ret(cpu, num, ret);
     return ret;
 efault:
     ret = -TARGET_EFAULT;
diff --git a/trace-events b/trace-events
index 9d76de8..4767059 100644
--- a/trace-events
+++ b/trace-events
@@ -156,3 +156,19 @@ memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsigned si
 #
 # Targets: TCG(all)
 disable vcpu tcg guest_mem_before(TCGv vaddr, uint8_t info) "info=%d", "vaddr=0x%016"PRIx64" info=%d"
+
+# @num: System call number.
+# @arg*: System call argument value.
+#
+# Start executing a guest system call in syscall emulation mode.
+#
+# Targets: TCG(all)
+disable vcpu guest_user_syscall(uint64_t num, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t arg7, uint64_t arg8) "num=0x%016"PRIx64" arg1=0x%016"PRIx64" arg2=0x%016"PRIx64" arg3=0x%016"PRIx64" arg4=0x%016"PRIx64" arg5=0x%016"PRIx64" arg6=0x%016"PRIx64" arg7=0x%016"PRIx64" arg8=0x%016"PRIx64
+
+# @num: System call number.
+# @ret: System call result value.
+#
+# Finish executing a guest system call in syscall emulation mode.
+#
+# Targets: TCG(all)
+disable vcpu guest_user_syscall_ret(uint64_t num, uint64_t ret) "num=0x%016"PRIx64" ret=0x%016"PRIx64
-- 
2.7.4

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

* Re: [Qemu-devel] [PULL 6/8] qemu-img: move common options parsing before commands processing
  2016-06-28 21:27 ` [Qemu-devel] [PULL 6/8] qemu-img: move common options parsing before commands processing Stefan Hajnoczi
@ 2016-06-29  8:22   ` Denis V. Lunev
  2016-07-01 16:39     ` Eric Blake
  0 siblings, 1 reply; 12+ messages in thread
From: Denis V. Lunev @ 2016-06-29  8:22 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel; +Cc: Peter Maydell, Paolo Bonzini, Kevin Wolf

On 06/29/2016 12:27 AM, Stefan Hajnoczi wrote:
> From: "Denis V. Lunev" <den@openvz.org>
>
> This is necessary to enable creation of common qemu-img options which will
> be specified before command.
>
> The patch also enables '-V' alias to '--version' (exactly like in other
> block utilities) and documents this change.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Message-id: 1466174654-30130-7-git-send-email-den@openvz.org
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>   qemu-img.c    | 41 +++++++++++++++++++++++++++--------------
>   qemu-img.texi | 10 +++++++++-
>   2 files changed, 36 insertions(+), 15 deletions(-)
>
> diff --git a/qemu-img.c b/qemu-img.c
> index 14e2661..2194c2d 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -91,9 +91,12 @@ static void QEMU_NORETURN help(void)
>   {
>       const char *help_msg =
>              QEMU_IMG_VERSION
> -           "usage: qemu-img command [command options]\n"
> +           "usage: qemu-img [standard options] command [command options]\n"
>              "QEMU disk image utility\n"
>              "\n"
> +           "    '-h', '--help'       display this help and exit\n"
> +           "    '-V', '--version'    output version information and exit\n"
> +           "\n"
>              "Command syntax:\n"
>   #define DEF(option, callback, arg_string)        \
>              "  " arg_string "\n"
> @@ -3806,7 +3809,7 @@ int main(int argc, char **argv)
>       int c;
>       static const struct option long_options[] = {
>           {"help", no_argument, 0, 'h'},
> -        {"version", no_argument, 0, 'v'},
> +        {"version", no_argument, 0, 'V'},
>           {0, 0, 0, 0}
>       };
>   
> @@ -3829,28 +3832,38 @@ int main(int argc, char **argv)
>       if (argc < 2) {
>           error_exit("Not enough arguments");
>       }
> -    cmdname = argv[1];
>   
>       qemu_add_opts(&qemu_object_opts);
>       qemu_add_opts(&qemu_source_opts);
>   
> +    while ((c = getopt_long(argc, argv, "+hV", long_options, NULL)) != -1) {
> +        switch (c) {
> +        case 'h':
> +            help();
> +            return 0;
> +        case 'V':
> +            printf(QEMU_IMG_VERSION);
> +            return 0;
> +        }
> +    }
> +
> +    cmdname = argv[optind];
> +
> +    /* reset getopt_long scanning */
> +    argc -= optind;
> +    if (argc < 1) {
> +        return 0;
> +    }
> +    argv += optind;
> +    optind = 1;
this patch breaks check-block.sh
we should have here
   'optind = 0'

Den

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

* Re: [Qemu-devel] [PULL 0/8] Tracing patches
  2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
                   ` (7 preceding siblings ...)
  2016-06-28 21:27 ` [Qemu-devel] [PULL 8/8] trace: [*-user] Add events to trace guest syscalls in syscall emulation mode Stefan Hajnoczi
@ 2016-06-29 15:08 ` Peter Maydell
  8 siblings, 0 replies; 12+ messages in thread
From: Peter Maydell @ 2016-06-29 15:08 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: QEMU Developers

On 28 June 2016 at 22:27, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> The following changes since commit d7f30403576f04f1f3a5fb5a1d18cba8dfa7a6d2:
>
>   cputlb: don't cpu_abort() if guest tries to execute outside RAM or RAM (2016-06-28 18:50:53 +0100)
>
> are available in the git repository at:
>
>   git://github.com/stefanha/qemu.git tags/tracing-pull-request
>
> for you to fetch changes up to 9c15e70086f3343bd810c6150d92ebfd6f346fcf:
>
>   trace: [*-user] Add events to trace guest syscalls in syscall emulation mode (2016-06-28 21:14:12 +0100)
>
> ----------------------------------------------------------------
>
> ----------------------------------------------------------------
>
> Denis V. Lunev (7):
>   doc: sync help description for --trace with man for qemu.1
>   doc: move text describing --trace to specific .texi file
>   trace: move qemu_trace_opts to trace/control.c
>   trace: enable tracing in qemu-io
>   trace: enable tracing in qemu-nbd
>   qemu-img: move common options parsing before commands processing
>   trace: enable tracing in qemu-img
>
> Lluís Vilanova (1):
>   trace: [*-user] Add events to trace guest syscalls in syscall
>     emulation mode
>

Applied, thanks.

-- PMM

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

* Re: [Qemu-devel] [PULL 6/8] qemu-img: move common options parsing before commands processing
  2016-06-29  8:22   ` Denis V. Lunev
@ 2016-07-01 16:39     ` Eric Blake
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Blake @ 2016-07-01 16:39 UTC (permalink / raw)
  To: Denis V. Lunev, Stefan Hajnoczi, qemu-devel
  Cc: Kevin Wolf, Peter Maydell, Paolo Bonzini

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

On 06/29/2016 02:22 AM, Denis V. Lunev wrote:
> On 06/29/2016 12:27 AM, Stefan Hajnoczi wrote:
>> From: "Denis V. Lunev" <den@openvz.org>
>>
>> This is necessary to enable creation of common qemu-img options which
>> will
>> be specified before command.

>> +    cmdname = argv[optind];
>> +
>> +    /* reset getopt_long scanning */
>> +    argc -= optind;
>> +    if (argc < 1) {
>> +        return 0;
>> +    }
>> +    argv += optind;
>> +    optind = 1;
> this patch breaks check-block.sh
> we should have here
>   'optind = 0'

Uggh. You've landed in one of the portability traps of getopt().  On
glibc, you can reset option parsing by assigning optind to 1 (but it
also works by assigning it to 0); on BSD, you instead set the variable
'optreset'; on Solaris, there is no way to reset option parsing (but
then again, Solaris doesn't maintain any invisible state like glibc or
BSD where you need to go out of your way to do a full reset).

But regardless of how you look at it, the patch has now been committed
to master without your suggested fix, so you'll have to propose a formal
followup patch as a new thread.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

end of thread, other threads:[~2016-07-01 16:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-28 21:27 [Qemu-devel] [PULL 0/8] Tracing patches Stefan Hajnoczi
2016-06-28 21:27 ` [Qemu-devel] [PULL 1/8] doc: sync help description for --trace with man for qemu.1 Stefan Hajnoczi
2016-06-28 21:27 ` [Qemu-devel] [PULL 2/8] doc: move text describing --trace to specific .texi file Stefan Hajnoczi
2016-06-28 21:27 ` [Qemu-devel] [PULL 3/8] trace: move qemu_trace_opts to trace/control.c Stefan Hajnoczi
2016-06-28 21:27 ` [Qemu-devel] [PULL 4/8] trace: enable tracing in qemu-io Stefan Hajnoczi
2016-06-28 21:27 ` [Qemu-devel] [PULL 5/8] trace: enable tracing in qemu-nbd Stefan Hajnoczi
2016-06-28 21:27 ` [Qemu-devel] [PULL 6/8] qemu-img: move common options parsing before commands processing Stefan Hajnoczi
2016-06-29  8:22   ` Denis V. Lunev
2016-07-01 16:39     ` Eric Blake
2016-06-28 21:27 ` [Qemu-devel] [PULL 7/8] trace: enable tracing in qemu-img Stefan Hajnoczi
2016-06-28 21:27 ` [Qemu-devel] [PULL 8/8] trace: [*-user] Add events to trace guest syscalls in syscall emulation mode Stefan Hajnoczi
2016-06-29 15:08 ` [Qemu-devel] [PULL 0/8] Tracing patches Peter Maydell

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