Patchwork [4/5] target-i386: get default cpu_model from QEMUMachine

login
register
mail settings
Submitter Igor Mammedov
Date April 30, 2013, 1:41 p.m.
Message ID <1367329288-27178-5-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/240620/
State New
Headers show

Comments

Igor Mammedov - April 30, 2013, 1:41 p.m.
allows to remove:
 * checks for cpu_model ==  NULL
 * and dynamic setting of default value

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/pc.c      |    9 ---------
 hw/i386/pc_piix.c |   16 ++++++++++++++--
 hw/i386/pc_q35.c  |    2 ++
 target-i386/cpu.h |    6 ++++++
 4 files changed, 22 insertions(+), 11 deletions(-)
Eduardo Habkost - April 30, 2013, 2:47 p.m.
On Tue, Apr 30, 2013 at 03:41:27PM +0200, Igor Mammedov wrote:
> allows to remove:
>  * checks for cpu_model ==  NULL
>  * and dynamic setting of default value
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

> ---
>  hw/i386/pc.c      |    9 ---------
>  hw/i386/pc_piix.c |   16 ++++++++++++++--
>  hw/i386/pc_q35.c  |    2 ++
>  target-i386/cpu.h |    6 ++++++
>  4 files changed, 22 insertions(+), 11 deletions(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 28f958d..0b75016 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -925,15 +925,6 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
>      X86CPU *cpu = NULL;
>      Error *error = NULL;
>  
> -    /* init CPUs */
> -    if (cpu_model == NULL) {
> -#ifdef TARGET_X86_64
> -        cpu_model = "qemu64";
> -#else
> -        cpu_model = "qemu32";
> -#endif
> -    }
> -
>      for (i = 0; i < smp_cpus; i++) {
>          cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),
>                           icc_bridge, &error);
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 3717796..465c48b 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -295,8 +295,6 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
>      const char *kernel_cmdline = args->kernel_cmdline;
>      const char *initrd_filename = args->initrd_filename;
>      const char *boot_device = args->boot_device;
> -    if (cpu_model == NULL)
> -        cpu_model = "486";
>      disable_kvm_pv_eoi();
>      enable_compat_apic_id_mode();
>      pc_init1(get_system_memory(),
> @@ -323,6 +321,7 @@ static QEMUMachine pc_i440fx_machine_v1_5 = {
>      .desc = "Standard PC (i440FX + PIIX, 1996)",
>      .init = pc_init_pci,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .is_default = 1,
>      DEFAULT_MACHINE_OPTIONS,
>  };
> @@ -332,6 +331,7 @@ static QEMUMachine pc_i440fx_machine_v1_4 = {
>      .desc = "Standard PC (i440FX + PIIX, 1996)",
>      .init = pc_init_pci_1_4,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_1_4,
>          { /* end of list */ }
> @@ -364,6 +364,7 @@ static QEMUMachine pc_machine_v1_3 = {
>      .desc = "Standard PC",
>      .init = pc_init_pci_1_3,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_1_3,
>          { /* end of list */ }
> @@ -404,6 +405,7 @@ static QEMUMachine pc_machine_v1_2 = {
>      .desc = "Standard PC",
>      .init = pc_init_pci_1_2,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_1_2,
>          { /* end of list */ }
> @@ -448,6 +450,7 @@ static QEMUMachine pc_machine_v1_1 = {
>      .desc = "Standard PC",
>      .init = pc_init_pci_1_2,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_1_1,
>          { /* end of list */ }
> @@ -484,6 +487,7 @@ static QEMUMachine pc_machine_v1_0 = {
>      .desc = "Standard PC",
>      .init = pc_init_pci_1_0,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_1_0,
>          { /* end of list */ }
> @@ -500,6 +504,7 @@ static QEMUMachine pc_machine_v0_15 = {
>      .desc = "Standard PC",
>      .init = pc_init_pci_1_0,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_0_15,
>          { /* end of list */ }
> @@ -533,6 +538,7 @@ static QEMUMachine pc_machine_v0_14 = {
>      .desc = "Standard PC",
>      .init = pc_init_pci_1_0,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_0_14, 
>          {
> @@ -567,6 +573,7 @@ static QEMUMachine pc_machine_v0_13 = {
>      .desc = "Standard PC",
>      .init = pc_init_pci_no_kvmclock,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_0_13,
>          {
> @@ -605,6 +612,7 @@ static QEMUMachine pc_machine_v0_12 = {
>      .desc = "Standard PC",
>      .init = pc_init_pci_no_kvmclock,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_0_12,
>          {
> @@ -639,6 +647,7 @@ static QEMUMachine pc_machine_v0_11 = {
>      .desc = "Standard PC, qemu 0.11",
>      .init = pc_init_pci_no_kvmclock,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_0_11,
>          {
> @@ -661,6 +670,7 @@ static QEMUMachine pc_machine_v0_10 = {
>      .desc = "Standard PC, qemu 0.10",
>      .init = pc_init_pci_no_kvmclock,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .compat_props = (GlobalProperty[]) {
>          PC_COMPAT_0_11,
>          {
> @@ -694,6 +704,7 @@ static QEMUMachine isapc_machine = {
>      .name = "isapc",
>      .desc = "ISA-only PC",
>      .init = pc_init_isa,
> +    .cpu_model = "486",
>      .max_cpus = 1,
>      .compat_props = (GlobalProperty[]) {
>          {
> @@ -712,6 +723,7 @@ static QEMUMachine xenfv_machine = {
>      .desc = "Xen Fully-virtualized PC",
>      .init = pc_xen_hvm_init,
>      .max_cpus = HVM_MAX_VCPUS,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      .default_machine_opts = "accel=xen",
>      DEFAULT_MACHINE_OPTIONS,
>  };
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 073543e..ab864db 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -214,6 +214,7 @@ static QEMUMachine pc_q35_machine_v1_5 = {
>      .desc = "Standard PC (Q35 + ICH9, 2009)",
>      .init = pc_q35_init,
>      .max_cpus = 255,
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      DEFAULT_MACHINE_OPTIONS,
>  };
>  
> @@ -226,6 +227,7 @@ static QEMUMachine pc_q35_machine_v1_4 = {
>          PC_COMPAT_1_4,
>          { /* end of list */ }
>      },
> +    .cpu_model = DEFAULT_X86CPU_MODEL,
>      DEFAULT_MACHINE_OPTIONS,
>  };
>  
> diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> index f193752..a49f68a 100644
> --- a/target-i386/cpu.h
> +++ b/target-i386/cpu.h
> @@ -896,6 +896,12 @@ typedef struct CPUX86State {
>  
>  #include "cpu-qom.h"
>  
> +#ifdef TARGET_X86_64
> +#define DEFAULT_X86CPU_MODEL "qemu64"
> +#else
> +#define DEFAULT_X86CPU_MODEL "qemu32"
> +#endif
> +
>  X86CPU *cpu_x86_init(const char *cpu_model);
>  X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge,
>                         Error **errp);
> -- 
> 1.7.1
>

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 28f958d..0b75016 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -925,15 +925,6 @@  void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
     X86CPU *cpu = NULL;
     Error *error = NULL;
 
-    /* init CPUs */
-    if (cpu_model == NULL) {
-#ifdef TARGET_X86_64
-        cpu_model = "qemu64";
-#else
-        cpu_model = "qemu32";
-#endif
-    }
-
     for (i = 0; i < smp_cpus; i++) {
         cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),
                          icc_bridge, &error);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 3717796..465c48b 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -295,8 +295,6 @@  static void pc_init_isa(QEMUMachineInitArgs *args)
     const char *kernel_cmdline = args->kernel_cmdline;
     const char *initrd_filename = args->initrd_filename;
     const char *boot_device = args->boot_device;
-    if (cpu_model == NULL)
-        cpu_model = "486";
     disable_kvm_pv_eoi();
     enable_compat_apic_id_mode();
     pc_init1(get_system_memory(),
@@ -323,6 +321,7 @@  static QEMUMachine pc_i440fx_machine_v1_5 = {
     .desc = "Standard PC (i440FX + PIIX, 1996)",
     .init = pc_init_pci,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .is_default = 1,
     DEFAULT_MACHINE_OPTIONS,
 };
@@ -332,6 +331,7 @@  static QEMUMachine pc_i440fx_machine_v1_4 = {
     .desc = "Standard PC (i440FX + PIIX, 1996)",
     .init = pc_init_pci_1_4,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_1_4,
         { /* end of list */ }
@@ -364,6 +364,7 @@  static QEMUMachine pc_machine_v1_3 = {
     .desc = "Standard PC",
     .init = pc_init_pci_1_3,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_1_3,
         { /* end of list */ }
@@ -404,6 +405,7 @@  static QEMUMachine pc_machine_v1_2 = {
     .desc = "Standard PC",
     .init = pc_init_pci_1_2,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_1_2,
         { /* end of list */ }
@@ -448,6 +450,7 @@  static QEMUMachine pc_machine_v1_1 = {
     .desc = "Standard PC",
     .init = pc_init_pci_1_2,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_1_1,
         { /* end of list */ }
@@ -484,6 +487,7 @@  static QEMUMachine pc_machine_v1_0 = {
     .desc = "Standard PC",
     .init = pc_init_pci_1_0,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_1_0,
         { /* end of list */ }
@@ -500,6 +504,7 @@  static QEMUMachine pc_machine_v0_15 = {
     .desc = "Standard PC",
     .init = pc_init_pci_1_0,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_0_15,
         { /* end of list */ }
@@ -533,6 +538,7 @@  static QEMUMachine pc_machine_v0_14 = {
     .desc = "Standard PC",
     .init = pc_init_pci_1_0,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_0_14, 
         {
@@ -567,6 +573,7 @@  static QEMUMachine pc_machine_v0_13 = {
     .desc = "Standard PC",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_0_13,
         {
@@ -605,6 +612,7 @@  static QEMUMachine pc_machine_v0_12 = {
     .desc = "Standard PC",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_0_12,
         {
@@ -639,6 +647,7 @@  static QEMUMachine pc_machine_v0_11 = {
     .desc = "Standard PC, qemu 0.11",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_0_11,
         {
@@ -661,6 +670,7 @@  static QEMUMachine pc_machine_v0_10 = {
     .desc = "Standard PC, qemu 0.10",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .compat_props = (GlobalProperty[]) {
         PC_COMPAT_0_11,
         {
@@ -694,6 +704,7 @@  static QEMUMachine isapc_machine = {
     .name = "isapc",
     .desc = "ISA-only PC",
     .init = pc_init_isa,
+    .cpu_model = "486",
     .max_cpus = 1,
     .compat_props = (GlobalProperty[]) {
         {
@@ -712,6 +723,7 @@  static QEMUMachine xenfv_machine = {
     .desc = "Xen Fully-virtualized PC",
     .init = pc_xen_hvm_init,
     .max_cpus = HVM_MAX_VCPUS,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     .default_machine_opts = "accel=xen",
     DEFAULT_MACHINE_OPTIONS,
 };
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 073543e..ab864db 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -214,6 +214,7 @@  static QEMUMachine pc_q35_machine_v1_5 = {
     .desc = "Standard PC (Q35 + ICH9, 2009)",
     .init = pc_q35_init,
     .max_cpus = 255,
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     DEFAULT_MACHINE_OPTIONS,
 };
 
@@ -226,6 +227,7 @@  static QEMUMachine pc_q35_machine_v1_4 = {
         PC_COMPAT_1_4,
         { /* end of list */ }
     },
+    .cpu_model = DEFAULT_X86CPU_MODEL,
     DEFAULT_MACHINE_OPTIONS,
 };
 
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index f193752..a49f68a 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -896,6 +896,12 @@  typedef struct CPUX86State {
 
 #include "cpu-qom.h"
 
+#ifdef TARGET_X86_64
+#define DEFAULT_X86CPU_MODEL "qemu64"
+#else
+#define DEFAULT_X86CPU_MODEL "qemu32"
+#endif
+
 X86CPU *cpu_x86_init(const char *cpu_model);
 X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge,
                        Error **errp);