qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>
Subject: [PATCH 2/3] plugins: Free CPUPluginState before destroying vCPU state
Date: Thu,  6 Jun 2024 14:40:09 +0200	[thread overview]
Message-ID: <20240606124010.2460-3-philmd@linaro.org> (raw)
In-Reply-To: <20240606124010.2460-1-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>
---
 include/qemu/plugin.h | 3 +++
 hw/core/cpu-common.c  | 5 +++++
 2 files changed, 8 insertions(+)

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 bf1a7b8892..cd15402552 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.41.0



  parent reply	other threads:[~2024-06-06 12:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06 12:40 [PATCH 0/3] plugins: Few debugging cleanups Philippe Mathieu-Daudé
2024-06-06 12:40 ` [PATCH 1/3] plugins: Ensure vCPU index is assigned in init/exit hooks Philippe Mathieu-Daudé
2024-06-06 21:13   ` Pierrick Bouvier
2024-06-06 12:40 ` Philippe Mathieu-Daudé [this message]
2024-06-06 21:14   ` [PATCH 2/3] plugins: Free CPUPluginState before destroying vCPU state Pierrick Bouvier
2024-06-07  4:53     ` Philippe Mathieu-Daudé
2024-06-07 16:13       ` Pierrick Bouvier
2024-06-06 12:40 ` [PATCH 3/3] accel/tcg: Move qemu_plugin_vcpu_init__async() to plugins/ Philippe Mathieu-Daudé
2024-06-13 10:52 ` [PATCH 0/3] plugins: Few debugging cleanups Philippe Mathieu-Daudé
2024-07-04 10:13 ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240606124010.2460-3-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=eduardo@habkost.net \
    --cc=erdnaxe@crans.org \
    --cc=ma.mandourr@gmail.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wangyanan55@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).