[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 19/38] cpu: hook plugin vcpu events
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [RFC v2 19/38] cpu: hook plugin vcpu events |
Date: |
Sun, 9 Dec 2018 14:37:30 -0500 |
Signed-off-by: Emilio G. Cota <address@hidden>
---
cpus.c | 10 ++++++++++
exec.c | 2 ++
qom/cpu.c | 2 ++
3 files changed, 14 insertions(+)
diff --git a/cpus.c b/cpus.c
index c9acef73e4..e3844c69c8 100644
--- a/cpus.c
+++ b/cpus.c
@@ -43,6 +43,7 @@
#include "exec/exec-all.h"
#include "qemu/thread.h"
+#include "qemu/plugin.h"
#include "sysemu/cpus.h"
#include "sysemu/qtest.h"
#include "qemu/main-loop.h"
@@ -1322,12 +1323,21 @@ static void qemu_tcg_rr_wait_io_event(CPUState *cpu)
static void qemu_wait_io_event(CPUState *cpu)
{
+ bool slept = false;
+
g_assert(cpu_mutex_locked(cpu));
g_assert(!qemu_mutex_iothread_locked());
while (cpu_thread_is_idle(cpu)) {
+ if (!slept) {
+ slept = true;
+ qemu_plugin_vcpu_idle_cb(cpu);
+ }
qemu_cond_wait(&cpu->halt_cond, &cpu->lock);
}
+ if (slept) {
+ qemu_plugin_vcpu_resume_cb(cpu);
+ }
#ifdef _WIN32
/* Eat dummy APC queued by qemu_cpu_kick_thread. */
diff --git a/exec.c b/exec.c
index 04d505500b..bdafb0e71a 100644
--- a/exec.c
+++ b/exec.c
@@ -967,6 +967,8 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
}
tlb_init(cpu);
+ qemu_plugin_vcpu_init_hook(cpu);
+
#ifndef CONFIG_USER_ONLY
if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu);
diff --git a/qom/cpu.c b/qom/cpu.c
index b33d182c4c..6233a98a84 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -32,6 +32,7 @@
#include "hw/boards.h"
#include "hw/qdev-properties.h"
#include "trace-root.h"
+#include "qemu/plugin.h"
CPUInterruptHandler cpu_interrupt_handler;
@@ -352,6 +353,7 @@ static void cpu_common_unrealizefn(DeviceState *dev, Error
**errp)
CPUState *cpu = CPU(dev);
/* NOTE: latest generic point before the cpu is fully unrealized */
trace_fini_vcpu(cpu);
+ qemu_plugin_vcpu_exit_hook(cpu);
cpu_exec_unrealizefn(cpu);
}
--
2.17.1
- [Qemu-devel] [RFC v2 21/38] translator: add translator_ld{ub, sw, uw, l, q}, (continued)
- [Qemu-devel] [RFC v2 21/38] translator: add translator_ld{ub, sw, uw, l, q}, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 10/38] plugin-gen: add module for TCG-related code, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 25/38] target/i386: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 38/38] tests/plugin: add sample plugins, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 37/38] linux-user: support -plugin option, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 27/38] target/m68k: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 29/38] target/riscv: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 22/38] target/arm: call qemu_plugin_insn_append, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 08/38] tcg: drop nargs from tcg_op_insert_{before, after}, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 19/38] cpu: hook plugin vcpu events,
Emilio G. Cota <=
- [Qemu-devel] [RFC v2 20/38] plugin-gen: add plugin_insn_append, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 35/38] configure: add --enable-plugins, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 28/38] target/alpha: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 26/38] target/hppa: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 36/38] vl: support -plugin option, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 34/38] plugin: add API symbols to qemu-plugins.symbols, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 30/38] target/sparc: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 31/38] target/xtensa: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 33/38] translator: inject instrumentation from plugins, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 32/38] target/openrisc: fetch code with translator_ld, Emilio G. Cota, 2018/12/09