@@ -27,7 +27,6 @@
#include "qemu/bitmap.h"
#include "qemu/queue.h"
#include "qemu/thread.h"
-#include "trace/generated-events.h"
typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size,
void *opaque);
@@ -240,6 +239,13 @@ struct qemu_work_item {
bool free;
};
+
+/* Keep this a multiple of 8, or better yet a multiple
+ * of the platform word size, since the struct
+ * will be padded out to that regardless.
+ */
+#define TRACE_MAX_VCPU_EVENT 32
+
/**
* CPUState:
* @cpu_index: CPU index (informative).
@@ -351,7 +357,7 @@ struct CPUState {
struct kvm_run *kvm_run;
/* Used for events with 'vcpu' and *without* the 'disabled' properties */
- DECLARE_BITMAP(trace_dstate, TRACE_VCPU_EVENT_COUNT);
+ DECLARE_BITMAP(trace_dstate, TRACE_MAX_VCPU_EVENT);
/* TODO Move common fields from CPUArchState here. */
int cpu_index; /* used by alpha TCG */
@@ -345,7 +345,7 @@ static void cpu_common_initfn(Object *obj)
qemu_mutex_init(&cpu->work_mutex);
QTAILQ_INIT(&cpu->breakpoints);
QTAILQ_INIT(&cpu->watchpoints);
- bitmap_zero(cpu->trace_dstate, TRACE_VCPU_EVENT_COUNT);
+ bitmap_zero(cpu->trace_dstate, TRACE_MAX_VCPU_EVENT);
}
static void cpu_common_finalize(Object *obj)
@@ -31,6 +31,7 @@ typedef struct TraceEventGroup {
size_t nevents;
} TraceEventGroup;
+static bool have_vcpu_events;
static TraceEventGroup *event_groups;
static size_t nevent_groups;
@@ -67,6 +68,20 @@ QemuOptsList qemu_trace_opts = {
void trace_event_register_group(TraceEvent *events,
size_t nevents)
{
+ size_t nvcpuevents = 0;
+ for (size_t i = 0; i < nevents; i++) {
+ if (events[i].vcpu_id != TRACE_VCPU_EVENT_COUNT) {
+ nvcpuevents++;
+ }
+ }
+
+ if (nvcpuevents) {
+ /* We only support 1 group having vcpu events */
+ assert(!have_vcpu_events);
+ assert(nvcpuevents < TRACE_MAX_VCPU_EVENT);
+ have_vcpu_events = true;
+ }
+
event_groups = g_renew(TraceEventGroup, event_groups, nevent_groups + 1);
event_groups[nevent_groups].events = events;
event_groups[nevent_groups].nevents = nevents;
@@ -19,6 +19,7 @@ typedef struct TraceEventIter {
const char *pattern;
} TraceEventIter;
+
/**
* TraceEventID:
*
The CPUState struct has a bitmap tracking which VCPU events are currently active. This is indexed based on the event ID values, and sized according the maximum TraceEventVCPUID enum value. Since there will the possibility of having multiple event groups, the indexes will potentially overlap. Rather than creating a more complex 2 dimensional data structure in CPUState, make an assumption that all the per-VCPU events will be defined in the same event group. Do a sanity check for this assumption when registering event groups. In addition, rather than using the TRACE_VCPU_EVENT_COUNT constant, which requires pulling in the enourmous trace events header, define a fixed bitmap size, which allows for 32 events. This will suffice for the immediate future and can be easily raised later if needed. With this change, the cpu.h file no longer has a direct dependancy on the generate events header file. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- include/qom/cpu.h | 10 ++++++++-- qom/cpu.c | 2 +- trace/control.c | 15 +++++++++++++++ trace/control.h | 1 + 4 files changed, 25 insertions(+), 3 deletions(-)