qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 8/9] trace: Allow event name pattern in "info trace-e


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PULL 8/9] trace: Allow event name pattern in "info trace-events"
Date: Mon, 18 Jul 2016 23:00:18 +0100

From: Lluís Vilanova <address@hidden>

Homogenizes the command capabilities with QMP.

Signed-off-by: Lluís Vilanova <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 hmp-commands-info.hx |  8 +++++---
 hmp.h                |  1 +
 monitor.c            | 31 ++++++++++++++++++++++++++++++-
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 7da9e6c..3d07ca6 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -646,10 +646,12 @@ ETEXI
 
     {
         .name       = "trace-events",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show available trace-events & their state",
+        .args_type  = "name:s?",
+        .params     = "[name]",
+        .help       = "show available trace-events & their state "
+                      "(name: event name pattern)",
         .mhandler.cmd = hmp_info_trace_events,
+        .command_completion = info_trace_events_completion,
     },
 
 STEXI
diff --git a/hmp.h b/hmp.h
index f5d9749..0876ec0 100644
--- a/hmp.h
+++ b/hmp.h
@@ -115,6 +115,7 @@ void set_link_completion(ReadLineState *rs, int nb_args, 
const char *str);
 void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str);
 void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str);
 void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str);
+void info_trace_events_completion(ReadLineState *rs, int nb_args, const char 
*str);
 void trace_event_completion(ReadLineState *rs, int nb_args, const char *str);
 void watchdog_action_completion(ReadLineState *rs, int nb_args,
                                 const char *str);
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;
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]