]> git.proxmox.com Git - mirror_qemu.git/blame - trace/qmp.c
target/s390x: Fix assertion failure in VFMIN/VFMAX with type 13
[mirror_qemu.git] / trace / qmp.c
CommitLineData
1dde0f48
LV
1/*
2 * QMP commands for tracing events.
3 *
77e2b172 4 * Copyright (C) 2014-2016 Lluís Vilanova <vilanova@ac.upc.edu>
1dde0f48
LV
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9
d38ea87a 10#include "qemu/osdep.h"
e688df6b 11#include "qapi/error.h"
9af23989 12#include "qapi/qapi-commands-trace.h"
333df1c6 13#include "control.h"
1dde0f48
LV
14
15
89aafcf2 16static bool check_events(bool ignore_unavailable, bool is_pattern,
77e2b172
LV
17 const char *name, Error **errp)
18{
19 if (!is_pattern) {
20 TraceEvent *ev = trace_event_name(name);
21
22 /* error for non-existing event */
23 if (ev == NULL) {
24 error_setg(errp, "unknown event \"%s\"", name);
25 return false;
26 }
27
77e2b172
LV
28 /* error for unavailable event */
29 if (!ignore_unavailable && !trace_event_get_state_static(ev)) {
30 error_setg(errp, "event \"%s\" is disabled", name);
31 return false;
32 }
33
34 return true;
35 } else {
36 /* error for unavailable events */
0d4e995c
DB
37 TraceEventIter iter;
38 TraceEvent *ev;
117856c3 39 trace_event_iter_init_pattern(&iter, name);
0d4e995c 40 while ((ev = trace_event_iter_next(&iter)) != NULL) {
77e2b172
LV
41 if (!ignore_unavailable && !trace_event_get_state_static(ev)) {
42 error_setg(errp, "event \"%s\" is disabled", trace_event_get_name(ev));
43 return false;
44 }
45 }
46 return true;
47 }
48}
49
50TraceEventInfoList *qmp_trace_event_get_state(const char *name,
51 bool has_vcpu, int64_t vcpu,
52 Error **errp)
53{
1dde0f48 54 TraceEventInfoList *events = NULL;
0d4e995c 55 TraceEventIter iter;
1dde0f48 56 TraceEvent *ev;
77e2b172 57 bool is_pattern = trace_event_is_pattern(name);
77e2b172
LV
58
59 /* Check events */
89aafcf2 60 if (!check_events(true, is_pattern, name, errp)) {
77e2b172
LV
61 return NULL;
62 }
63
64 /* Get states (all errors checked above) */
117856c3 65 trace_event_iter_init_pattern(&iter, name);
0d4e995c 66 while ((ev = trace_event_iter_next(&iter)) != NULL) {
54aa3de7 67 TraceEventInfo *value;
77e2b172 68
54aa3de7 69 value = g_new(TraceEventInfo, 1);
54aa3de7 70 value->name = g_strdup(trace_event_get_name(ev));
77e2b172 71
1dde0f48 72 if (!trace_event_get_state_static(ev)) {
54aa3de7 73 value->state = TRACE_EVENT_STATE_UNAVAILABLE;
1dde0f48 74 } else {
89aafcf2
AB
75 if (trace_event_get_state_dynamic(ev)) {
76 value->state = TRACE_EVENT_STATE_ENABLED;
77e2b172 77 } else {
89aafcf2 78 value->state = TRACE_EVENT_STATE_DISABLED;
77e2b172 79 }
1dde0f48 80 }
54aa3de7 81 QAPI_LIST_PREPEND(events, value);
1dde0f48
LV
82 }
83
84 return events;
85}
86
87void qmp_trace_event_set_state(const char *name, bool enable,
77e2b172
LV
88 bool has_ignore_unavailable, bool ignore_unavailable,
89 bool has_vcpu, int64_t vcpu,
90 Error **errp)
1dde0f48 91{
0d4e995c 92 TraceEventIter iter;
1dde0f48 93 TraceEvent *ev;
77e2b172 94 bool is_pattern = trace_event_is_pattern(name);
77e2b172
LV
95
96 /* Check events */
89aafcf2 97 if (!check_events(has_ignore_unavailable && ignore_unavailable,
77e2b172 98 is_pattern, name, errp)) {
1dde0f48
LV
99 return;
100 }
101
77e2b172 102 /* Apply changes (all errors checked above) */
117856c3 103 trace_event_iter_init_pattern(&iter, name);
0d4e995c 104 while ((ev = trace_event_iter_next(&iter)) != NULL) {
89aafcf2 105 if (!trace_event_get_state_static(ev)) {
77e2b172
LV
106 continue;
107 }
89aafcf2 108 trace_event_set_state_dynamic(ev, enable);
1dde0f48
LV
109 }
110}