qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 2/2] system/cpus: Fix resume_all_vcpus() under vCPU hotplug co


From: Keqian Zhu
Subject: [PATCH v1 2/2] system/cpus: Fix resume_all_vcpus() under vCPU hotplug condition
Date: Sun, 17 Mar 2024 16:37:04 +0800

For vCPU being hotplugged, qemu_init_vcpu() is called. In this
function, we set vcpu state as stopped, and then wait vcpu thread
to be created.

As the vcpu state is stopped, it will inform us it has been created
and then wait on halt_cond. After we has realized vcpu object, we
will resume the vcpu thread.

However, during we wait vcpu thread to be created, the bql is
unlocked, and other thread is allowed to call resume_all_vcpus(),
which will resume the un-realized vcpu.

This fixes the issue by filter out un-realized vcpu during
resume_all_vcpus().

Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
---
 system/cpus.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/system/cpus.c b/system/cpus.c
index 4e41abe23e..8871f5dfa9 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -638,6 +638,9 @@ void resume_all_vcpus(void)
 
     qemu_clock_enable(QEMU_CLOCK_VIRTUAL, true);
     CPU_FOREACH(cpu) {
+        if (!object_property_get_bool(OBJECT(cpu), "realized", &error_abort)) {
+            continue;
+        }
         cpu_resume(cpu);
     }
 }
-- 
2.33.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]