[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 36/73] cpu: hook plugin vcpu events
From: |
Alex Bennée |
Subject: |
[PULL v2 36/73] cpu: hook plugin vcpu events |
Date: |
Fri, 25 Oct 2019 07:36:36 +0100 |
From: "Emilio G. Cota" <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
diff --git a/cpus.c b/cpus.c
index fabbeca6f46..63bda152f57 100644
--- a/cpus.c
+++ b/cpus.c
@@ -45,6 +45,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"
@@ -1264,9 +1265,18 @@ static void qemu_tcg_rr_wait_io_event(void)
static void qemu_wait_io_event(CPUState *cpu)
{
+ bool slept = false;
+
while (cpu_thread_is_idle(cpu)) {
+ if (!slept) {
+ slept = true;
+ qemu_plugin_vcpu_idle_cb(cpu);
+ }
qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
}
+ 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 fb0943cfed6..1feda0ca761 100644
--- a/exec.c
+++ b/exec.c
@@ -975,6 +975,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/hw/core/cpu.c b/hw/core/cpu.c
index 73b1ee34d04..db1a03c6bbb 100644
--- a/hw/core/cpu.c
+++ b/hw/core/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.20.1
- [PULL v2 22/73] plugin: add user-facing API, (continued)
- [PULL v2 22/73] plugin: add user-facing API, Alex Bennée, 2019/10/25
- [PULL v2 12/73] travis.yml: cache the clang sanitizer build, Alex Bennée, 2019/10/25
- [PULL v2 21/73] docs/devel: add plugins.rst design document, Alex Bennée, 2019/10/25
- [PULL v2 65/73] tests/plugin: add a hotblocks plugin, Alex Bennée, 2019/10/25
- [PULL v2 24/73] plugin: add implementation of the api, Alex Bennée, 2019/10/25
- [PULL v2 55/73] plugin: add qemu_plugin_insn_disas helper, Alex Bennée, 2019/10/25
- [PULL v2 40/73] target/arm: fetch code with translator_ld, Alex Bennée, 2019/10/25
- [PULL v2 52/73] configure: add --enable-plugins, Alex Bennée, 2019/10/25
- [PULL v2 28/73] tcg: add tcg_gen_st_ptr, Alex Bennée, 2019/10/25
- [PULL v2 71/73] scripts/checkpatch.pl: don't complain about (foo, /* empty */), Alex Bennée, 2019/10/25
- [PULL v2 36/73] cpu: hook plugin vcpu events,
Alex Bennée <=
- [PULL v2 58/73] linux-user: support -plugin option, Alex Bennée, 2019/10/25
- [PULL v2 38/73] cputlb: ensure _cmmu helper functions follow the naming standard, Alex Bennée, 2019/10/25
- [PULL v2 18/73] trace: add mmu_index to mem_info, Alex Bennée, 2019/10/25
- [PULL v2 20/73] translate-all: use cpu_in_exclusive_work_context() in tb_flush, Alex Bennée, 2019/10/25
- [PULL v2 30/73] atomic_template: add inline trace/plugin helpers, Alex Bennée, 2019/10/25
- [PULL v2 62/73] tests/tcg: move "virtual" tests to EXTRA_TESTS, Alex Bennée, 2019/10/25
- [PULL v2 49/73] target/xtensa: fetch code with translator_ld, Alex Bennée, 2019/10/25
- [PULL v2 60/73] tests/tcg/Makefile.target: fix path to config-host.mak, Alex Bennée, 2019/10/25
- [PULL v2 50/73] target/openrisc: fetch code with translator_ld, Alex Bennée, 2019/10/25
- [PULL v2 57/73] vl: support -plugin option, Alex Bennée, 2019/10/25