[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 17/29] plugins: fix order of init/idle/resume callback
From: |
Alex Bennée |
Subject: |
[PATCH v4 17/29] plugins: fix order of init/idle/resume callback |
Date: |
Tue, 27 Feb 2024 14:43:23 +0000 |
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
We found that vcpu_init_hook was called *after* idle callback.
vcpu_init is called from cpu_realize_fn, while idle/resume cb are called
from qemu_wait_io_event (in vcpu thread).
This change ensures we only call idle and resume cb only once a plugin
was init for a given vcpu.
Next change in the series will run vcpu_init asynchronously, which will
make it run *after* resume callback as well. So we fix this now.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240213094009.150349-4-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
plugins/core.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/plugins/core.c b/plugins/core.c
index caa66311351..2392bbb8889 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -391,12 +391,17 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t
num, int64_t ret)
void qemu_plugin_vcpu_idle_cb(CPUState *cpu)
{
- plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_IDLE);
+ /* idle and resume cb may be called before init, ignore in this case */
+ if (cpu->cpu_index < plugin.num_vcpus) {
+ plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_IDLE);
+ }
}
void qemu_plugin_vcpu_resume_cb(CPUState *cpu)
{
- plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME);
+ if (cpu->cpu_index < plugin.num_vcpus) {
+ plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME);
+ }
}
void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id,
--
2.39.2
- [PATCH v4 02/29] tests/tcg: bump TCG test timeout to 120s, (continued)
- [PATCH v4 02/29] tests/tcg: bump TCG test timeout to 120s, Alex Bennée, 2024/02/27
- [PATCH v4 01/29] tests/tcg: update licenses to GPLv2 as intended, Alex Bennée, 2024/02/27
- [PATCH v4 11/29] gdbstub: Simplify XML lookup, Alex Bennée, 2024/02/27
- [PATCH v4 09/29] gdbstub: Use GDBFeature for GDBRegisterState, Alex Bennée, 2024/02/27
- [PATCH v4 07/29] target/riscv: Use GDBFeature for dynamic XML, Alex Bennée, 2024/02/27
- [PATCH v4 12/29] gdbstub: Infer number of core registers from XML, Alex Bennée, 2024/02/27
- [PATCH v4 05/29] target/arm: Use GDBFeature for dynamic XML, Alex Bennée, 2024/02/27
- [PATCH v4 10/29] gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb, Alex Bennée, 2024/02/27
- [PATCH v4 08/29] gdbstub: Use GDBFeature for gdb_register_coprocessor, Alex Bennée, 2024/02/27
- [PATCH v4 06/29] target/ppc: Use GDBFeature for dynamic XML, Alex Bennée, 2024/02/27
- [PATCH v4 17/29] plugins: fix order of init/idle/resume callback,
Alex Bennée <=
- [PATCH v4 14/29] gdbstub: Add members to identify registers to GDBFeature, Alex Bennée, 2024/02/27
- [PATCH v4 13/29] hw/core/cpu: Remove gdb_get_dynamic_xml member, Alex Bennée, 2024/02/27
- [PATCH v4 15/29] plugins: remove previous n_vcpus functions from API, Alex Bennée, 2024/02/27
- [PATCH v4 16/29] plugins: add qemu_plugin_num_vcpus function, Alex Bennée, 2024/02/27
- [PATCH v4 25/29] contrib/plugins: fix imatch, Alex Bennée, 2024/02/27
- [PATCH v4 29/29] docs/devel: plugins can trigger a tb flush, Alex Bennée, 2024/02/27
- [PATCH v4 28/29] docs/devel: document some plugin assumptions, Alex Bennée, 2024/02/27
- [PATCH v4 21/29] gdbstub: expose api to find registers, Alex Bennée, 2024/02/27
- [PATCH v4 27/29] docs/devel: lift example and plugin API sections up, Alex Bennée, 2024/02/27