@@ -821,7 +821,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
CPUState *cs;
qemu_irq *input;
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
@@ -193,7 +193,7 @@ static void ppc_core99_init(MachineState *machine)
#endif
}
for (i = 0; i < smp_cpus; i++) {
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
@@ -113,7 +113,7 @@ static void ppc_heathrow_init(MachineState *machine)
if (machine->cpu_model == NULL)
machine->cpu_model = "G3";
for (i = 0; i < smp_cpus; i++) {
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
@@ -1352,7 +1352,12 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id)
return NULL;
}
-PowerPCCPU *ppc_cpu_init(const char *cpu_model)
+static void ppc_set_vcpu_dt_id(PowerPCCPU *cpu, int cpu_index, Error **errp)
+{
+ ;
+}
+
+PowerPCCPU *ppc_cpu_init(const char *cpu_model, int cpu_index)
{
PowerPCCPU *cpu;
CPUClass *cc;
@@ -1374,6 +1379,11 @@ PowerPCCPU *ppc_cpu_init(const char *cpu_model)
cpu = POWERPC_CPU(object_new(object_class_get_name(oc)));
+ ppc_set_vcpu_dt_id(cpu, cpu_index, &err);
+ if (err != NULL) {
+ goto out;
+ }
+
cc = CPU_CLASS(oc);
cc->parse_features(CPU(cpu), model_pieces[1], &err);
g_strfreev(model_pieces);
@@ -186,7 +186,7 @@ static void bamboo_init(MachineState *machine)
if (machine->cpu_model == NULL) {
machine->cpu_model = "440EP";
}
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, 0);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
@@ -509,7 +509,7 @@ static void ppc_prep_init(MachineState *machine)
if (machine->cpu_model == NULL)
machine->cpu_model = "602";
for (i = 0; i < smp_cpus; i++) {
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
@@ -1828,7 +1828,7 @@ static void ppc_spapr_init(MachineState *machine)
g_free(type);
} else {
for (i = 0; i < smp_cpus; i++) {
- PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model);
+ PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
error_report("Unable to find PowerPC CPU definition");
exit(1);
@@ -106,5 +106,5 @@ enum {
/* ppc_booke.c */
void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags);
-PowerPCCPU *ppc_cpu_init(const char *cpu_model);
+PowerPCCPU *ppc_cpu_init(const char *cpu_model, int cpu_index);
#endif
This patch introduces the ppc_set_vcpu_dt_id() function. It is currently empty but it will be used to generate cpu_dt_id out of a cpu_index provided by the machine. It also changes the machine types to provide cpu_index. Since all of them keep the cpus in an array, cpu_index is simply the index in the array. The only exception is pseries-2.7 which supports hotplug of cpu cores and already open codes the cpu creation. Its case will be covered in follow-up patch. Suggested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Greg Kurz <groug@kaod.org> --- hw/ppc/e500.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/ppc.c | 12 +++++++++++- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 2 +- include/hw/ppc/ppc.h | 2 +- 8 files changed, 18 insertions(+), 8 deletions(-)