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 1/3] plugins: Ensure vCPU index is assigned in init/exit hooks
Date: Thu, 6 Jun 2024 14:40:08 +0200 [thread overview]
Message-ID: <20240606124010.2460-2-philmd@linaro.org> (raw)
In-Reply-To: <20240606124010.2460-1-philmd@linaro.org>
Since vCPUs are hashed by their index, this index can't
be uninitialized (UNASSIGNED_CPU_INDEX).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
plugins/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/plugins/core.c b/plugins/core.c
index badede28cf..d339b3db4d 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -245,6 +245,7 @@ void qemu_plugin_vcpu_init_hook(CPUState *cpu)
{
bool success;
+ assert(cpu->cpu_index != UNASSIGNED_CPU_INDEX);
qemu_rec_mutex_lock(&plugin.lock);
plugin.num_vcpus = MAX(plugin.num_vcpus, cpu->cpu_index + 1);
plugin_cpu_update__locked(&cpu->cpu_index, NULL, NULL);
@@ -263,6 +264,7 @@ void qemu_plugin_vcpu_exit_hook(CPUState *cpu)
plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_EXIT);
+ assert(cpu->cpu_index != UNASSIGNED_CPU_INDEX);
qemu_rec_mutex_lock(&plugin.lock);
success = g_hash_table_remove(plugin.cpu_ht, &cpu->cpu_index);
g_assert(success);
--
2.41.0
next prev 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 ` Philippe Mathieu-Daudé [this message]
2024-06-06 21:13 ` [PATCH 1/3] plugins: Ensure vCPU index is assigned in init/exit hooks Pierrick Bouvier
2024-06-06 12:40 ` [PATCH 2/3] plugins: Free CPUPluginState before destroying vCPU state Philippe Mathieu-Daudé
2024-06-06 21:14 ` 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-2-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).