qom: add object_new_with_class

Similar to CPU and machine classes, "-accel" class names are mangled,
so we have to first get a class via accel_find and then instantiate it.
Provide a new function to instantiate a class without going through
object_class_get_name, and use it for CPUs and machines already.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2019-11-13 13:57:55 +01:00
parent 1fff3c206f
commit 3c75e12ea6
6 changed files with 25 additions and 11 deletions

View file

@ -440,7 +440,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
if (cpu_list_data->model) {
Object *obj;
S390CPU *sc;
obj = object_new(object_class_get_name(klass));
obj = object_new_with_class(klass);
sc = S390_CPU(obj);
if (sc->model) {
info->has_unavailable_features = true;
@ -498,7 +498,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
error_setg(errp, "The CPU definition '%s' requires KVM", info->name);
return;
}
obj = object_new(object_class_get_name(oc));
obj = object_new_with_class(oc);
cpu = S390_CPU(obj);
if (!cpu->model) {