diff mbox series

[RFC,6/7] DO NOT MERGE: acpi: cpuhp: use 'realized' status of vCPU to check if CPU is enabled

Message ID 20241112170258.2996640-7-imammedo@redhat.com (mailing list archive)
State New
Headers show
Series Fix broken cpu hotplug after migration | expand

Commit Message

Igor Mammedov Nov. 12, 2024, 5:02 p.m. UTC
it still correct for x86 and other users, and can serve us as simpler to
 [1] cpu_enabled_status() callback that does the same in a roundabout way.

It's still an RFC, and probably there we should add another property
'enabled' instead of abusing 'realized' and/or handle enabled state
using hotplug handlers chain. i.e. in plug handler store enabled state
AcpiCpuStatus and clear it in unplug handler instead of asking cpu from
MMIO handler directly.

1) bf1ecc8dad606 (w/acpi: Update ACPI `_STA` method with QOM vCPU ACPI Hotplug states)
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index 67513450f9..992ae5d233 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -63,7 +63,9 @@  static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size)
     cdev = &cpu_st->devs[cpu_st->selector];
     switch (addr) {
     case ACPI_CPU_FLAGS_OFFSET_RW: /* pack and return is_* fields */
-        val |= cdev->cpu ? 1 : 0;
+        val |= cdev->cpu ? object_property_get_bool(OBJECT(cdev->cpu),
+                                                    "realized", NULL)
+                           : 0;
         val |= cdev->is_inserting ? 2 : 0;
         val |= cdev->is_removing  ? 4 : 0;
         val |= cdev->fw_remove  ? 16 : 0;