aboutsummaryrefslogtreecommitdiff
path: root/hw/s390x
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2017-09-13 15:24:15 +0200
committerCornelia Huck <cohuck@redhat.com>2017-09-19 18:31:32 +0200
commit524d18d8bd463431b120eeb5f9f3d1064a1c19e4 (patch)
treee489796f78a1e73edd8b51ab9de8b3345fb3d212 /hw/s390x
parent2b44178d87f380eb0ca23ea93dda2146ea2e3fd0 (diff)
s390x: get rid of cpu_s390x_create()
Now that there is only one user of cpu_s390x_create() left, make cpu creation look like on x86. - Perform the model/properties split and checks in s390_init_cpus() - Parse features only once without having to remember if already parsed - Pass only the typename to s390x_new_cpu() - Use the typename of an existing CPU for hotplug via cpu-add Acked-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20170913132417.24384-21-david@redhat.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'hw/s390x')
-rw-r--r--hw/s390x/s390-virtio-ccw.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 0caf20b719..fafbc6d4fe 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -55,6 +55,10 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
static void s390_init_cpus(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
+ const char *typename;
+ gchar **model_pieces;
+ ObjectClass *oc;
+ CPUClass *cc;
int i;
if (machine->cpu_model == NULL) {
@@ -69,8 +73,25 @@ static void s390_init_cpus(MachineState *machine)
/* initialize possible_cpus */
mc->possible_cpu_arch_ids(machine);
+ model_pieces = g_strsplit(machine->cpu_model, ",", 2);
+ if (!model_pieces[0]) {
+ error_report("Invalid/empty CPU model name");
+ exit(1);
+ }
+
+ oc = cpu_class_by_name(TYPE_S390_CPU, model_pieces[0]);
+ if (!oc) {
+ error_report("Unable to find CPU definition: %s", model_pieces[0]);
+ exit(1);
+ }
+ typename = object_class_get_name(oc);
+ cc = CPU_CLASS(oc);
+ /* after parsing, properties will be applied to all *typename* instances */
+ cc->parse_features(typename, model_pieces[1], &error_fatal);
+ g_strfreev(model_pieces);
+
for (i = 0; i < smp_cpus; i++) {
- s390x_new_cpu(machine->cpu_model, i, &error_fatal);
+ s390x_new_cpu(typename, i, &error_fatal);
}
}
@@ -382,8 +403,12 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
static void s390_hot_add_cpu(const int64_t id, Error **errp)
{
MachineState *machine = MACHINE(qdev_get_machine());
+ ObjectClass *oc;
+
+ g_assert(machine->possible_cpus->cpus[0].cpu);
+ oc = OBJECT_CLASS(CPU_GET_CLASS(machine->possible_cpus->cpus[0].cpu));
- s390x_new_cpu(machine->cpu_model, id, errp);
+ s390x_new_cpu(object_class_get_name(oc), id, errp);
}
static void s390_nmi(NMIState *n, int cpu_index, Error **errp)