[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 21/33] machine: Add MachineClass.default_cpu_mode
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH v4 21/33] machine: Add MachineClass.default_cpu_model field |
Date: |
Thu, 14 Aug 2014 16:25:50 -0300 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH v4 11/33] pc: Register machine classes directly instead of using QEMUMachine, (continued)
- [Qemu-devel] [PATCH v4 11/33] pc: Register machine classes directly instead of using QEMUMachine, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 10/33] machine: Make compat_props a linked list, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 13/33] pc: Eliminate pc_default_machine_options(), Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 14/33] piix: Eliminate pc_i440fx_machine_options(), Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 15/33] q35: Eliminate pc_q35_machine_options(), Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 16/33] q35: Eliminate pc_q35_1_4_machine_options(), Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 17/33] pc: Eliminate all *_machine_options() functions, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 18/33] machine: Eliminate QEMUMachine.compat_props, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 19/33] pc: Rename pc_machine variable to pcms, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 20/33] pc: Pass PCMachineState argument to pc_cpus_init(), Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 21/33] machine: Add MachineClass.default_cpu_model field,
Eduardo Habkost <=
- [Qemu-devel] [PATCH v4 22/33] pc: Move globals to PCMachineClass, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 23/33] pc: Move option_rom_has_mr/rom_file_has_mr to MachineClass, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 24/33] pc: Add PCMachineClass.compat_apic_id_mode field, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 25/33] target-i386: Move error handling to end of x86_cpu_parse_featurestr(), Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 26/33] target-i386: Renove underscores from feature names, Eduardo Habkost, 2014/08/14
- [Qemu-devel] [PATCH v4 27/33] target-i386: Register X86CPU "feat-kvmclock" feature, Eduardo Habkost, 2014/08/14