Message ID | 20200520132003.9492-14-kraxel@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | microvm: add acpi support | expand |
On Wed, 20 May 2020 15:19:54 +0200 Gerd Hoffmann <kraxel@redhat.com> wrote: > 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 --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; > + } I'm thinking about removing x86_cpu_new alogether (in favor of device_add), so I'd preffer avoid adding direct access to possible_cpus here. that's the job of pc_cpu_plug (and possibly pc_cpu_pre_plug) in combination with static const TypeInfo pc_machine_info = { .name = TYPE_PC_MACHINE, ... .interfaces = (InterfaceInfo[]) { { TYPE_HOTPLUG_HANDLER }, { } }, }; I'd reuse common code if possible in microvm or make microvm specific simplified version of it if it makes job easier. > object_unref(cpu); > error_propagate(errp, local_err); > }
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); }
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(+)