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>
This commit is contained in:
David Hildenbrand 2017-09-13 15:24:15 +02:00 committed by Cornelia Huck
parent 2b44178d87
commit 524d18d8bd
4 changed files with 30 additions and 47 deletions

View file

@ -68,52 +68,11 @@ void s390x_cpu_timer(void *opaque)
}
#endif
S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp)
S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id, Error **errp)
{
static bool features_parsed;
char *name, *features;
const char *typename;
ObjectClass *oc;
CPUClass *cc;
name = g_strdup(cpu_model);
features = strchr(name, ',');
if (features) {
features[0] = 0;
features++;
}
oc = cpu_class_by_name(TYPE_S390_CPU, name);
if (!oc) {
error_setg(errp, "Unknown CPU definition \'%s\'", name);
g_free(name);
return NULL;
}
typename = object_class_get_name(oc);
if (!features_parsed) {
features_parsed = true;
cc = CPU_CLASS(oc);
cc->parse_features(typename, features, errp);
}
g_free(name);
if (*errp) {
return NULL;
}
return S390_CPU(CPU(object_new(typename)));
}
S390CPU *s390x_new_cpu(const char *cpu_model, uint32_t core_id, Error **errp)
{
S390CPU *cpu;
S390CPU *cpu = S390_CPU(object_new(typename));
Error *err = NULL;
cpu = cpu_s390x_create(cpu_model, &err);
if (err != NULL) {
goto out;
}
object_property_set_int(OBJECT(cpu), core_id, "core-id", &err);
if (err != NULL) {
goto out;