qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] i386: keep cpu_model field in MachineState uptodate
@ 2015-08-24  9:42 Zhu Guihua
  2015-08-26 15:11 ` Eduardo Habkost
  0 siblings, 1 reply; 3+ messages in thread
From: Zhu Guihua @ 2015-08-24  9:42 UTC (permalink / raw)
  To: qemu-devel, pbonzini, rth, mst, ehabkost; +Cc: Zhu Guihua

Update cpu_model in MachineState for i386, so that the field can be used
for cpu hotplug, instead of using a static variable.

Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
---
v2:
 -transfer MachineState from all pc_cpus_init() callers
---
 hw/i386/pc.c         | 16 +++++++---------
 hw/i386/pc_piix.c    |  2 +-
 hw/i386/pc_q35.c     |  2 +-
 include/hw/i386/pc.h |  2 +-
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 9f2924e..46ea74a 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1081,11 +1081,10 @@ out:
     return cpu;
 }
 
-static const char *current_cpu_model;
-
 void pc_hot_add_cpu(const int64_t id, Error **errp)
 {
     DeviceState *icc_bridge;
+    MachineState *machine = MACHINE(qdev_get_machine());
     X86CPU *cpu;
     int64_t apic_id = x86_cpu_apic_id_from_index(id);
     Error *local_err = NULL;
@@ -1116,7 +1115,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
 
     icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
                                                  TYPE_ICC_BRIDGE, NULL));
-    cpu = pc_new_cpu(current_cpu_model, apic_id, icc_bridge, &local_err);
+    cpu = pc_new_cpu(machine->cpu_model, apic_id, icc_bridge, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
@@ -1124,7 +1123,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
     object_unref(OBJECT(cpu));
 }
 
-void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
+void pc_cpus_init(MachineState *machine, DeviceState *icc_bridge)
 {
     int i;
     X86CPU *cpu = NULL;
@@ -1132,14 +1131,13 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
     unsigned long apic_id_limit;
 
     /* init CPUs */
-    if (cpu_model == NULL) {
+    if (machine->cpu_model == NULL) {
 #ifdef TARGET_X86_64
-        cpu_model = "qemu64";
+        machine->cpu_model = "qemu64";
 #else
-        cpu_model = "qemu32";
+        machine->cpu_model = "qemu32";
 #endif
     }
-    current_cpu_model = cpu_model;
 
     apic_id_limit = pc_apic_id_limit(max_cpus);
     if (apic_id_limit > ACPI_CPU_HOTPLUG_ID_LIMIT) {
@@ -1149,7 +1147,7 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
     }
 
     for (i = 0; i < smp_cpus; i++) {
-        cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),
+        cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i),
                          icc_bridge, &error);
         if (error) {
             error_report_err(error);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 9558467..7e16665 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -145,7 +145,7 @@ static void pc_init1(MachineState *machine)
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
 
-    pc_cpus_init(machine->cpu_model, icc_bridge);
+    pc_cpus_init(machine, icc_bridge);
 
     if (kvm_enabled() && kvmclock_enabled) {
         kvmclock_create();
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index c07d65b..e7249d2 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -136,7 +136,7 @@ static void pc_q35_init(MachineState *machine)
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
 
-    pc_cpus_init(machine->cpu_model, icc_bridge);
+    pc_cpus_init(machine, icc_bridge);
     pc_acpi_init("q35-acpi-dsdt.aml");
 
     kvmclock_create();
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index d0cad87..ae0184d 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -161,7 +161,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms);
 void pc_register_ferr_irq(qemu_irq irq);
 void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
-void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge);
+void pc_cpus_init(MachineState *machine, DeviceState *icc_bridge);
 void pc_hot_add_cpu(const int64_t id, Error **errp);
 void pc_acpi_init(const char *default_dsdt);
 
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] i386: keep cpu_model field in MachineState uptodate
  2015-08-24  9:42 [Qemu-devel] [PATCH v2] i386: keep cpu_model field in MachineState uptodate Zhu Guihua
@ 2015-08-26 15:11 ` Eduardo Habkost
  2015-08-27  3:17   ` Zhu Guihua
  0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Habkost @ 2015-08-26 15:11 UTC (permalink / raw)
  To: Zhu Guihua; +Cc: pbonzini, mst, qemu-devel, rth

On Mon, Aug 24, 2015 at 05:42:09PM +0800, Zhu Guihua wrote:
> Update cpu_model in MachineState for i386, so that the field can be used
> for cpu hotplug, instead of using a static variable.
> 
> Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
[...]
> -void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
> +void pc_cpus_init(MachineState *machine, DeviceState *icc_bridge)

This is a PC initialization function, so a PCMachineState argument makes
more sense. See pc_cmos_init(), load_linux(), pc_guest_info_init(),
pc_memory_init(), etc.

The rest looks good.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] i386: keep cpu_model field in MachineState uptodate
  2015-08-26 15:11 ` Eduardo Habkost
@ 2015-08-27  3:17   ` Zhu Guihua
  0 siblings, 0 replies; 3+ messages in thread
From: Zhu Guihua @ 2015-08-27  3:17 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: pbonzini, mst, qemu-devel, rth


On 08/26/2015 11:11 PM, Eduardo Habkost wrote:
> On Mon, Aug 24, 2015 at 05:42:09PM +0800, Zhu Guihua wrote:
>> Update cpu_model in MachineState for i386, so that the field can be used
>> for cpu hotplug, instead of using a static variable.
>>
>> Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
> [...]
>> -void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
>> +void pc_cpus_init(MachineState *machine, DeviceState *icc_bridge)
> This is a PC initialization function, so a PCMachineState argument makes
> more sense. See pc_cmos_init(), load_linux(), pc_guest_info_init(),
> pc_memory_init(), etc.

Oh, I know how to do this. Thanks for your suggestion.

Thanks,
Zhu

>
> The rest looks good.
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-27  3:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24  9:42 [Qemu-devel] [PATCH v2] i386: keep cpu_model field in MachineState uptodate Zhu Guihua
2015-08-26 15:11 ` Eduardo Habkost
2015-08-27  3:17   ` Zhu Guihua

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).