On Thu, Dec 10, 2015 at 11:45:37AM +0530, Bharata B Rao wrote: > Storing CPU typename in MachineState lets us to create CPU threads > for all architectures in uniform manner from arch-neutral code. > > TODO: Touching only i386 and spapr targets for now > > Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com>
Suggestions: * Name the field "cpu_base_type" to indicate it is the base CPU class name, not the actual CPU class name used when creating CPUs. * Put it in MachineClass, as it may be useful for code that runs before machine->init(), in the future. * Maybe make it a CPUClass* field instead of a string? > --- > hw/i386/pc.c | 1 + > hw/ppc/spapr.c | 2 ++ > include/hw/boards.h | 1 + > 3 files changed, 4 insertions(+) > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 5e20e07..ffcd645 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1133,6 +1133,7 @@ void pc_cpus_init(PCMachineState *pcms) > machine->cpu_model = "qemu32"; > #endif > } > + machine->cpu_type = TYPE_X86_CPU; > > apic_id_limit = pc_apic_id_limit(max_cpus); > if (apic_id_limit > ACPI_CPU_HOTPLUG_ID_LIMIT) { > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 030ee35..db441f2 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -1797,6 +1797,8 @@ static void ppc_spapr_init(MachineState *machine) > if (machine->cpu_model == NULL) { > machine->cpu_model = kvm_enabled() ? "host" : "POWER7"; > } > + machine->cpu_type = TYPE_POWERPC_CPU; > + > for (i = 0; i < smp_cpus; i++) { > cpu = cpu_ppc_init(machine->cpu_model); > if (cpu == NULL) { > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 24eb6f0..a1f9512 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -128,6 +128,7 @@ struct MachineState { > char *kernel_cmdline; > char *initrd_filename; > const char *cpu_model; > + const char *cpu_type; > AccelState *accelerator; > }; > > -- > 2.1.0 > -- Eduardo