diff options
author | Denis V. Lunev <den@openvz.org> | 2016-06-17 17:44:10 +0300 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-06-28 21:14:12 +0100 |
commit | e9e0bb2af2248eabafb54402e3127f9f8a8690f5 (patch) | |
tree | c3d12e495c54d54b3006eff6435c031933114216 /trace/control.c | |
parent | eeb2b8f78d614e0245c978d0da8beaba49a89f2e (diff) |
trace: move qemu_trace_opts to trace/control.c
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>
Diffstat (limited to 'trace/control.c')
-rw-r--r-- | trace/control.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/trace/control.c b/trace/control.c index e1556a3570..86de8b9983 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; +} |