aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-10-04 14:35:43 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2016-10-12 09:35:54 +0200
commit0d4e995c7368f8bdc8845beb499b650386a38819 (patch)
treea2daca965ac8ccf0e9e54ab6a71c60c74b2a2e23 /monitor.c
parent6a1b0f3aea09142cb8989ccffb3b74bb8808a00f (diff)
trace: convert code to use event iterators
This converts the HMP/QMP monitor API implementations and some internal trace control methods to use the new trace event iterator APIs. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: LluĂ­s Vilanova <vilanova@ac.upc.edu> Message-id: 1475588159-30598-5-git-send-email-berrange@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/monitor.c b/monitor.c
index b07f254698..8728dd9fa5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3330,13 +3330,14 @@ void info_trace_events_completion(ReadLineState *rs, int nb_args, const char *st
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);
- }
+ TraceEventIter iter;
+ TraceEvent *ev;
+ char *pattern = g_strdup_printf("%s*", str);
+ trace_event_iter_init(&iter, pattern);
+ while ((ev = trace_event_iter_next(&iter)) != NULL) {
+ readline_add_completion(rs, trace_event_get_name(ev));
}
+ g_free(pattern);
}
}
@@ -3347,13 +3348,14 @@ void trace_event_completion(ReadLineState *rs, int nb_args, const char *str)
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);
- }
+ TraceEventIter iter;
+ TraceEvent *ev;
+ char *pattern = g_strdup_printf("%s*", str);
+ trace_event_iter_init(&iter, pattern);
+ while ((ev = trace_event_iter_next(&iter)) != NULL) {
+ readline_add_completion(rs, trace_event_get_name(ev));
}
+ g_free(pattern);
} else if (nb_args == 3) {
add_completion_option(rs, str, "on");
add_completion_option(rs, str, "off");