[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 13/20] instrument: Add event 'guest_cpu_exit'
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH v4 13/20] instrument: Add event 'guest_cpu_exit' |
Date: |
Wed, 6 Sep 2017 21:15:11 +0300 |
User-agent: |
StGit/0.17.1-dirty |
Signed-off-by: Lluís Vilanova <address@hidden>
---
instrument/control.c | 9 +++++++++
instrument/events.h | 3 +++
instrument/events.inc.h | 11 +++++++++++
instrument/load.c | 1 +
instrument/qemu-instr/control.h | 9 +++++++++
stubs/instrument.c | 1 +
trace/control.c | 4 +++-
7 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/instrument/control.c b/instrument/control.c
index ed0d537b88..09ba682483 100644
--- a/instrument/control.c
+++ b/instrument/control.c
@@ -57,3 +57,12 @@ QI_VPUBLIC void qi_event_set_guest_cpu_enter(void
(*fn)(QICPU vcpu))
ERROR_IF(!instr_get_state(), "called outside instrumentation");
instr_set_event(guest_cpu_enter, fn);
}
+
+
+void (*instr_event__guest_cpu_exit)(QICPU vcpu);
+
+QI_VPUBLIC void qi_event_set_guest_cpu_exit(void (*fn)(QICPU vcpu))
+{
+ ERROR_IF(!instr_get_state(), "called outside instrumentation");
+ instr_set_event(guest_cpu_exit, fn);
+}
diff --git a/instrument/events.h b/instrument/events.h
index 947f120aa9..c743cb8180 100644
--- a/instrument/events.h
+++ b/instrument/events.h
@@ -36,6 +36,9 @@ extern void *instr_event__fini_data;
extern void (*instr_event__guest_cpu_enter)(QICPU vcpu);
static inline void instr_guest_cpu_enter(CPUState *vcpu);
+extern void (*instr_event__guest_cpu_exit)(QICPU vcpu);
+static inline void instr_guest_cpu_exit(CPUState *vcpu);
+
#include "instrument/events.inc.h"
diff --git a/instrument/events.inc.h b/instrument/events.inc.h
index 238cce9855..bcbf0cb32a 100644
--- a/instrument/events.inc.h
+++ b/instrument/events.inc.h
@@ -20,3 +20,14 @@ static inline void instr_guest_cpu_enter(CPUState *vcpu)
instr_set_state(INSTR_STATE_DISABLE);
}
}
+
+static inline void instr_guest_cpu_exit(CPUState *vcpu)
+{
+ void (*cb)(QICPU vcpu) = instr_get_event(guest_cpu_exit);
+ if (cb) {
+ QICPU vcpu_ = instr_cpu_set(vcpu);
+ instr_set_state(INSTR_STATE_ENABLE);
+ (*cb)(vcpu_);
+ instr_set_state(INSTR_STATE_DISABLE);
+ }
+}
diff --git a/instrument/load.c b/instrument/load.c
index 0fe878afa8..63b7d564ec 100644
--- a/instrument/load.c
+++ b/instrument/load.c
@@ -149,6 +149,7 @@ InstrUnloadError instr_unload(int64_t handle_id)
instr_set_event(fini_fn, NULL);
instr_set_event(guest_cpu_enter, NULL);
+ instr_set_event(guest_cpu_exit, NULL);
/* this should never fail */
if (dlclose(handle->dlhandle) < 0) {
diff --git a/instrument/qemu-instr/control.h b/instrument/qemu-instr/control.h
index 26d8aa976d..c37a380ab0 100644
--- a/instrument/qemu-instr/control.h
+++ b/instrument/qemu-instr/control.h
@@ -80,6 +80,15 @@ void qi_set_fini(qi_fini_fn fn, void *data);
*/
void qi_event_set_guest_cpu_enter(void (*fn)(QICPU vcpu));
+/*
+ * Hot-unplug a virtual (guest) CPU.
+ *
+ * Mode: user, softmmu
+ * Targets: all
+ * Time: exec
+ */
+void qi_event_set_guest_cpu_exit(void (*fn)(QICPU vcpu));
+
#ifdef __cplusplus
}
#endif
diff --git a/stubs/instrument.c b/stubs/instrument.c
index 658a872e1c..ea8df6d467 100644
--- a/stubs/instrument.c
+++ b/stubs/instrument.c
@@ -12,3 +12,4 @@
__thread InstrState instr_cur_state;
void (*instr_event__guest_cpu_enter)(QICPU *vcpu);
+void (*instr_event__guest_cpu_exit)(QICPU *vcpu);
diff --git a/trace/control.c b/trace/control.c
index 82d8989c4d..946a0af818 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -1,13 +1,14 @@
/*
* Interface for configuring and controlling the state of tracing events.
*
- * Copyright (C) 2011-2016 Lluís Vilanova <address@hidden>
+ * Copyright (C) 2011-2017 Lluís Vilanova <address@hidden>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#include "qemu/osdep.h"
+#include "instrument/events.h"
#include "trace/control.h"
#include "qemu/help_option.h"
#ifdef CONFIG_TRACE_SIMPLE
@@ -272,6 +273,7 @@ void trace_fini_vcpu(CPUState *vcpu)
TraceEventIter iter;
TraceEvent *ev;
+ instr_guest_cpu_exit(vcpu);
trace_guest_cpu_exit(vcpu);
trace_event_iter_init(&iter, NULL);
- Re: [Qemu-devel] [PATCH v4 08/20] instrument: [hmp] Add library loader, (continued)
- [Qemu-devel] [PATCH v4 09/20] instrument: Add basic control interface, Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 10/20] instrument: Add support for tracing events, Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 11/20] instrument: Track vCPUs, Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 12/20] instrument: Add event 'guest_cpu_enter', Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 13/20] instrument: Add event 'guest_cpu_exit',
Lluís Vilanova <=
- [Qemu-devel] [PATCH v4 14/20] instrument: Add event 'guest_cpu_reset', Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 15/20] trace: Introduce a proper structure to describe memory accesses, Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 16/20] instrument: Add event 'guest_mem_before_trans', Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 17/20] instrument: Add event 'guest_mem_before_exec', Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 18/20] instrument: Add event 'guest_user_syscall', Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 19/20] instrument: Add event 'guest_user_syscall_ret', Lluís Vilanova, 2017/09/06
- [Qemu-devel] [PATCH v4 20/20] instrument: Add API to manipulate guest memory, Lluís Vilanova, 2017/09/06
- Re: [Qemu-devel] [PATCH v4 00/20] instrument: Add basic event instrumentation, Emilio G. Cota, 2017/09/06