Message ID | 1463227273-27523-2-git-send-email-den@openvz.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 14/05/2016 14:01, Denis V. Lunev wrote: > It would be convinient to enable tracepoints in qemu-io binary. This would > allow to perform investigations without additional code recompilations. > > The command line will be exactly the same as in qemu-system. > > Signed-off-by: Denis V. Lunev <den@openvz.org> > CC: Kevin Wolf <kwolf@redhat.com> > CC: Paolo Bonzini <pbonzini@redhat.com> > --- > qemu-io.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/qemu-io.c b/qemu-io.c > index 5ef3ef7..2d0d2b0 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" Why does this need qemu/log.h, as opposed to trace/control.h (which probably should be moved to include/qemu/trace.h, but that's a patch for another day)? > #include "qapi/qmp/qstring.h" > #include "qom/object_interfaces.h" > #include "sysemu/block-backend.h" > @@ -419,6 +420,25 @@ static QemuOptsList qemu_object_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 */ } > + }, > +}; Stefan, should this be in trace/control.c instead, so that vl.c and qemu-io.c can share it? Otherwise looks sane. Thanks, Paolo > static QemuOptsList file_opts = { > .name = "file", > @@ -473,6 +493,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,10 +533,32 @@ int main(int argc, char **argv) > } > break; > case 'T': > + { > + QemuOpts *trace_opts; > + char *trace_file; > + > + trace_opts = qemu_opts_parse_noisily(qemu_find_opts("trace"), > + optarg, true); > + if (trace_opts == NULL) { > + exit(1); > + } > + if (qemu_opt_get(trace_opts, "enable")) { > + trace_enable_events(qemu_opt_get(trace_opts, "enable")); > + } > + trace_init_events(qemu_opt_get(trace_opts, "events")); > + > + trace_file = g_strdup(qemu_opt_get(trace_opts, "file")); > + qemu_opts_del(trace_opts); > + > if (!trace_init_backends()) { > exit(1); /* error message will have been printed */ > } > + trace_init_file(trace_file); > + g_free(trace_file); > + > + qemu_set_log(LOG_TRACE); > break; > + } > case 'V': > printf("%s version %s\n", progname, QEMU_VERSION); > exit(0); >
On 05/16/2016 04:09 PM, Paolo Bonzini wrote: > > On 14/05/2016 14:01, Denis V. Lunev wrote: >> It would be convinient to enable tracepoints in qemu-io binary. This would >> allow to perform investigations without additional code recompilations. >> >> The command line will be exactly the same as in qemu-system. >> >> Signed-off-by: Denis V. Lunev <den@openvz.org> >> CC: Kevin Wolf <kwolf@redhat.com> >> CC: Paolo Bonzini <pbonzini@redhat.com> >> --- >> qemu-io.c | 43 +++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 43 insertions(+) >> >> diff --git a/qemu-io.c b/qemu-io.c >> index 5ef3ef7..2d0d2b0 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" > Why does this need qemu/log.h, as opposed to trace/control.h (which > probably should be moved to include/qemu/trace.h, but that's a patch for > another day)? no, this is necessary for qemu_set_log(LOG_TRACE); which is performed as a last step to enable tracing.
On 05/14/2016 06:01 AM, Denis V. Lunev wrote: > It would be convinient to enable tracepoints in qemu-io binary. This would s/convinient/convenient/ > allow to perform investigations without additional code recompilations. > > The command line will be exactly the same as in qemu-system. Reads awkwardly. Grammar suggestion for the whole commit body: For convenience, enable tracepoints in the qemu-io binary just like what is done for qemu-system. This allows trace investigations without additional code recompilation. > > Signed-off-by: Denis V. Lunev <den@openvz.org> > CC: Kevin Wolf <kwolf@redhat.com> > CC: Paolo Bonzini <pbonzini@redhat.com> > --- > qemu-io.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) >
diff --git a/qemu-io.c b/qemu-io.c index 5ef3ef7..2d0d2b0 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" @@ -419,6 +420,25 @@ static QemuOptsList qemu_object_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 file_opts = { .name = "file", @@ -473,6 +493,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,10 +533,32 @@ int main(int argc, char **argv) } break; case 'T': + { + QemuOpts *trace_opts; + char *trace_file; + + trace_opts = qemu_opts_parse_noisily(qemu_find_opts("trace"), + optarg, true); + if (trace_opts == NULL) { + exit(1); + } + if (qemu_opt_get(trace_opts, "enable")) { + trace_enable_events(qemu_opt_get(trace_opts, "enable")); + } + trace_init_events(qemu_opt_get(trace_opts, "events")); + + trace_file = g_strdup(qemu_opt_get(trace_opts, "file")); + qemu_opts_del(trace_opts); + if (!trace_init_backends()) { exit(1); /* error message will have been printed */ } + trace_init_file(trace_file); + g_free(trace_file); + + qemu_set_log(LOG_TRACE); break; + } case 'V': printf("%s version %s\n", progname, QEMU_VERSION); exit(0);
It would be convinient to enable tracepoints in qemu-io binary. This would allow to perform investigations without additional code recompilations. The command line will be exactly the same as in qemu-system. Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Kevin Wolf <kwolf@redhat.com> CC: Paolo Bonzini <pbonzini@redhat.com> --- qemu-io.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)