Instead of making the machine-specific init code set a default CPU model, make the generic machine init code set cpu_model to a class-specific default if it is not set.
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> --- hw/i386/pc.c | 12 +++++------- hw/i386/pc_piix.c | 4 +--- include/hw/boards.h | 3 +++ vl.c | 3 ++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b42ff69..1aec670 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1022,13 +1022,6 @@ void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge) MachineState *machine = MACHINE(pcms); /* init CPUs */ - if (machine->cpu_model == NULL) { -#ifdef TARGET_X86_64 - machine->cpu_model = "qemu64"; -#else - machine->cpu_model = "qemu32"; -#endif - } current_cpu_model = machine->cpu_model; apic_id_limit = pc_apic_id_limit(max_cpus); @@ -1692,6 +1685,11 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order = "cad"; mc->hot_add_cpu = pc_hot_add_cpu; mc->max_cpus = 255; +#ifdef TARGET_X86_64 + mc->default_cpu_model = "qemu64"; +#else + mc->default_cpu_model = "qemu32"; +#endif hc->plug = pc_machine_device_plug_cb; } diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 8045fee..ad364b0 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -430,9 +430,6 @@ static void pc_init_isa(MachineState *machine) has_reserved_memory = false; option_rom_has_mr = true; rom_file_has_mr = false; - if (!machine->cpu_model) { - machine->cpu_model = "486"; - } x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); enable_compat_apic_id_mode(); pc_init1(machine); @@ -988,6 +985,7 @@ static void isapc_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus = 1; mc->hot_add_cpu = NULL; mc->name = "isapc"; + mc->default_cpu_model = "486"; machine_class_add_compat_props(mc, compat_props); } diff --git a/include/hw/boards.h b/include/hw/boards.h index bbc7a9d..ca78f46 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -66,6 +66,8 @@ extern MachineState *current_machine; /** * MachineClass: * @qemu_machine: #QEMUMachine + * @default_cpu_model: CPU model to be used if no CPU model is provided + * by the user. * @get_hotplug_handler: this function is called during bus-less * device hotplug. If defined it returns pointer to an instance * of HotplugHandler object, which handles hotplug operation @@ -100,6 +102,7 @@ struct MachineClass { const char *default_boot_order; GList *compat_props; const char *hw_version; + const char *default_cpu_model; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); diff --git a/vl.c b/vl.c index b004f84..c1c5ac8 100644 --- a/vl.c +++ b/vl.c @@ -4418,7 +4418,8 @@ int main(int argc, char **argv, char **envp) current_machine->maxram_size = maxram_size; current_machine->ram_slots = ram_slots; current_machine->boot_order = boot_order; - current_machine->cpu_model = cpu_model; + current_machine->cpu_model = + cpu_model ? cpu_model : machine_class->default_cpu_model; machine_class->init(current_machine); -- 1.9.3