diff mbox series

[v3,13/22] x86: coldplug cpus

Message ID 20200520132003.9492-14-kraxel@redhat.com
State New
Headers show
Series microvm: add acpi support | expand

Commit Message

Gerd Hoffmann May 20, 2020, 1:19 p.m. UTC
microvm needs this, for correct madt creation
(make sure enable bit is set).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/i386/x86.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 7a3bc7ab6639..ac7a0a958781 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -118,6 +118,7 @@  uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,
 
 void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)
 {
+    MachineClass *mc = MACHINE_GET_CLASS(x86ms);
     Object *cpu = NULL;
     Error *local_err = NULL;
 
@@ -126,6 +127,16 @@  void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)
     object_property_set_uint(cpu, apic_id, "apic-id", &local_err);
     object_property_set_bool(cpu, true, "realized", &local_err);
 
+    if (!mc->has_hotpluggable_cpus) {
+        /* coldplug cpu */
+        MachineState *ms = MACHINE(x86ms);
+        int i = 0;
+        while (ms->possible_cpus->cpus[i].arch_id != apic_id) {
+            i++;
+        }
+        ms->possible_cpus->cpus[i].cpu = cpu;
+    }
+
     object_unref(cpu);
     error_propagate(errp, local_err);
 }