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: eblake@redhat.com, "Denis V. Lunev" <den@openvz.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c
Date: Tue, 14 Jun 2016 13:08:15 +0300	[thread overview]
Message-ID: <1465898899-1586-4-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1465898899-1586-1-git-send-email-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>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
---
 trace/control.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
 trace/control.h | 24 +++++++++++++-----------
 vl.c            | 37 +------------------------------------
 3 files changed, 57 insertions(+), 48 deletions(-)

diff --git a/trace/control.c b/trace/control.c
index d099f73..75fc731 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -20,11 +20,33 @@
 #include "qemu/log.h"
 #endif
 #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);
@@ -141,7 +163,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;
@@ -216,3 +238,23 @@ 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"));
+    if (trace_file) {
+        g_free(trace_file);
+    }
+    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..942f9f5 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,19 @@ 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
+ * @trace_file: current filename to save traces to
+ *
+ * Initialize tracing subsystem.
+ */
+char *trace_opt_parse(const char *optarg, char *trace_file);
 
 #include "trace/control-internal.h"
 
diff --git a/vl.c b/vl.c
index b0bcc25..7d72599 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",
@@ -3872,23 +3852,8 @@ 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);
+                trace_file = trace_opt_parse(optarg, trace_file);
                 break;
-            }
             case QEMU_OPTION_readconfig:
                 {
                     int ret = qemu_read_config_file(optarg);
-- 
2.1.4

  parent reply	other threads:[~2016-06-14 10:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 1/7] doc: move text describing --trace to specific .texi file Denis V. Lunev
2016-06-14 21:49   ` Eric Blake
2016-06-14 21:50     ` Eric Blake
2016-06-14 10:08 ` [Qemu-devel] [PATCH 2/7] doc: sync help descriprion for --trace with man for qemu.1 Denis V. Lunev
2016-06-14 21:50   ` Eric Blake
2016-06-14 10:08 ` Denis V. Lunev [this message]
2016-06-14 10:08 ` [Qemu-devel] [PATCH 4/7] trace: enable tracing in qemu-io Denis V. Lunev
2016-06-14 10:08 ` [Qemu-devel] [PATCH 5/7] trace: enable tracing in qemu-nbd Denis V. Lunev
2016-06-14 21:51   ` Eric Blake
2016-06-14 10:08 ` [Qemu-devel] [PATCH 6/7] qemu-img: move common options parsing before commands processing 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
  -- strict thread matches above, loose matches on Subject: below --
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 3/7] trace: move qemu_trace_opts to trace/control.c Denis V. Lunev
2016-06-17 13:48 [Qemu-devel] [PATCH v8 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-17 13:48 ` [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c 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 3/7] trace: move qemu_trace_opts to trace/control.c Denis V. Lunev
2016-06-17 13:48   ` Stefan Hajnoczi
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:16 ` [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c 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=1465898899-1586-4-git-send-email-den@openvz.org \
    --to=den@openvz.org \
    --cc=eblake@redhat.com \
    --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.