aboutsummaryrefslogtreecommitdiff
path: root/trace/qmp.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 /trace/qmp.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 'trace/qmp.c')
-rw-r--r--trace/qmp.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/trace/qmp.c b/trace/qmp.c
index 11d2564e7b..ac777d154f 100644
--- a/trace/qmp.c
+++ b/trace/qmp.c
@@ -52,8 +52,10 @@ static bool check_events(bool has_vcpu, bool ignore_unavailable, bool is_pattern
return true;
} else {
/* error for unavailable events */
- TraceEvent *ev = NULL;
- while ((ev = trace_event_pattern(name, ev)) != NULL) {
+ TraceEventIter iter;
+ TraceEvent *ev;
+ trace_event_iter_init(&iter, name);
+ while ((ev = trace_event_iter_next(&iter)) != NULL) {
if (!ignore_unavailable && !trace_event_get_state_static(ev)) {
error_setg(errp, "event \"%s\" is disabled", trace_event_get_name(ev));
return false;
@@ -69,6 +71,7 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
{
Error *err = NULL;
TraceEventInfoList *events = NULL;
+ TraceEventIter iter;
TraceEvent *ev;
bool is_pattern = trace_event_is_pattern(name);
CPUState *cpu;
@@ -86,8 +89,8 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
}
/* Get states (all errors checked above) */
- ev = NULL;
- while ((ev = trace_event_pattern(name, ev)) != NULL) {
+ trace_event_iter_init(&iter, name);
+ while ((ev = trace_event_iter_next(&iter)) != NULL) {
TraceEventInfoList *elem;
bool is_vcpu = trace_event_is_vcpu(ev);
if (has_vcpu && !is_vcpu) {
@@ -132,6 +135,7 @@ void qmp_trace_event_set_state(const char *name, bool enable,
Error **errp)
{
Error *err = NULL;
+ TraceEventIter iter;
TraceEvent *ev;
bool is_pattern = trace_event_is_pattern(name);
CPUState *cpu;
@@ -150,8 +154,8 @@ void qmp_trace_event_set_state(const char *name, bool enable,
}
/* Apply changes (all errors checked above) */
- ev = NULL;
- while ((ev = trace_event_pattern(name, ev)) != NULL) {
+ trace_event_iter_init(&iter, name);
+ while ((ev = trace_event_iter_next(&iter)) != NULL) {
if (!trace_event_get_state_static(ev) ||
(has_vcpu && !trace_event_is_vcpu(ev))) {
continue;