[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 28/40] plugins: Free CPUPluginState before destroying vCPU state
From: |
Alex Bennée |
Subject: |
[PULL 28/40] plugins: Free CPUPluginState before destroying vCPU state |
Date: |
Fri, 5 Jul 2024 16:30:40 +0100 |
From: Philippe Mathieu-Daudé <philmd@linaro.org>
cpu::plugin_state is allocated in cpu_common_initfn() when
the vCPU state is created. Release it in cpu_common_finalize()
when we are done.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240606124010.2460-3-philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-29-alex.bennee@linaro.org>
diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index bc5aef979e..af5f9db469 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -149,6 +149,9 @@ struct CPUPluginState {
/**
* qemu_plugin_create_vcpu_state: allocate plugin state
+ *
+ * The returned data must be released with g_free()
+ * when no longer required.
*/
CPUPluginState *qemu_plugin_create_vcpu_state(void);
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index f131cde2c0..8f6cb64da3 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -283,6 +283,11 @@ static void cpu_common_finalize(Object *obj)
{
CPUState *cpu = CPU(obj);
+#ifdef CONFIG_PLUGIN
+ if (tcg_enabled()) {
+ g_free(cpu->plugin_state);
+ }
+#endif
g_array_free(cpu->gdb_regs, TRUE);
qemu_lockcnt_destroy(&cpu->in_ioctl_lock);
qemu_mutex_destroy(&cpu->work_mutex);
--
2.39.2
- [PULL 29/40] accel/tcg: Move qemu_plugin_vcpu_init__async() to plugins/, (continued)
- [PULL 29/40] accel/tcg: Move qemu_plugin_vcpu_init__async() to plugins/, Alex Bennée, 2024/07/05
- [PULL 34/40] target/arm: Make some MTE helpers widely available, Alex Bennée, 2024/07/05
- [PULL 25/40] plugins/lockstep: mention the one-insn-per-tb option, Alex Bennée, 2024/07/05
- [PULL 24/40] plugins/lockstep: make mixed-mode safe, Alex Bennée, 2024/07/05
- [PULL 23/40] plugins/lockstep: preserve sock_path, Alex Bennée, 2024/07/05
- [PULL 36/40] gdbstub: Make hex conversion function non-internal, Alex Bennée, 2024/07/05
- [PULL 39/40] gdbstub: Add support for MTE in user mode, Alex Bennée, 2024/07/05
- [PULL 18/40] tests/tcg/arm: Use vmrs/vmsr instead of mcr/mrc, Alex Bennée, 2024/07/05
- [PULL 19/40] linux-user/main: Suppress out-of-range comparison warning for clang, Alex Bennée, 2024/07/05
- [PULL 28/40] plugins: Free CPUPluginState before destroying vCPU state,
Alex Bennée <=
- [PULL 38/40] gdbstub: Use true to set cmd_startswith, Alex Bennée, 2024/07/05
- [PULL 33/40] target/arm: Fix exception case in allocation_tag_mem_probe, Alex Bennée, 2024/07/05
- [PULL 30/40] gdbstub: Clean up process_string_cmd, Alex Bennée, 2024/07/05
- [PULL 26/40] plugins/lockstep: clean-up output, Alex Bennée, 2024/07/05
- [PULL 22/40] test/plugins: preserve the instruction record over translations, Alex Bennée, 2024/07/05
- [PULL 20/40] gitlab: don't bother with KVM for TCI builds, Alex Bennée, 2024/07/05
- [PULL 31/40] gdbstub: Move GdbCmdParseEntry into a new header file, Alex Bennée, 2024/07/05
- Re: [PULL 00/40] maintainer updates for testing, plugins and gdbstub, Richard Henderson, 2024/07/05