aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorLluís Vilanova <vilanova@ac.upc.edu>2016-07-11 12:53:51 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2016-07-18 18:23:12 +0100
commitbd71211d556aac5451696785fbe29be7f70bed05 (patch)
treee7492c51c6afce6a71a9e5d90ad20d07db53c071 /monitor.c
parent40b9cd25f789e02145fda5e1f3fde7e7dd9e3b61 (diff)
downloadqemu-bd71211d556aac5451696785fbe29be7f70bed05.zip
qemu-bd71211d556aac5451696785fbe29be7f70bed05.tar.gz
qemu-bd71211d556aac5451696785fbe29be7f70bed05.tar.bz2
trace: Allow event name pattern in "info trace-events"
Homogenizes the command capabilities with QMP. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/monitor.c b/monitor.c
index d0ff246..ab31725 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1065,8 +1065,20 @@ static void hmp_info_cpustats(Monitor *mon, const QDict *qdict)
static void hmp_info_trace_events(Monitor *mon, const QDict *qdict)
{
- TraceEventInfoList *events = qmp_trace_event_get_state("*", NULL);
+ const char *name = qdict_get_try_str(qdict, "name");
+ TraceEventInfoList *events;
TraceEventInfoList *elem;
+ Error *local_err = NULL;
+
+ if (name == NULL) {
+ name = "*";
+ }
+
+ events = qmp_trace_event_get_state(name, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ return;
+ }
for (elem = events; elem != NULL; elem = elem->next) {
monitor_printf(mon, "%s : state %u\n",
@@ -3296,6 +3308,23 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str)
}
}
+void info_trace_events_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+ size_t len;
+
+ len = strlen(str);
+ readline_set_completion_index(rs, len);
+ if (nb_args == 2) {
+ TraceEventID id;
+ for (id = 0; id < trace_event_count(); id++) {
+ const char *event_name = trace_event_get_name(trace_event_id(id));
+ if (!strncmp(str, event_name, len)) {
+ readline_add_completion(rs, event_name);
+ }
+ }
+ }
+}
+
void trace_event_completion(ReadLineState *rs, int nb_args, const char *str)
{
size_t len;