]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
qom: let object_new use a module if the type is not present
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 29 Oct 2024 09:41:58 +0000 (10:41 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 31 Oct 2024 17:28:32 +0000 (18:28 +0100)
object_initialize() can use modules (it was added there because
virtio-gpu-device is a child device of virtio-gpu-pci; commit
64f7aece8ea, "object_initialize: try module load", 2020-09-15).
object_new() cannot; make things consistent.

qdev_new() is now just a simple wrapper that returns DeviceState.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/core/qdev.c
qom/object.c

index 2f740fa55e96b78192d5c4ae4b9b329d2f788551..5f13111b77c10d8fa5f5c08697cc0592678b4fab 100644 (file)
@@ -146,22 +146,6 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp)
 
 DeviceState *qdev_new(const char *name)
 {
-    ObjectClass *oc = object_class_by_name(name);
-#ifdef CONFIG_MODULES
-    if (!oc) {
-        int rv = module_load_qom(name, &error_fatal);
-        if (rv > 0) {
-            oc = object_class_by_name(name);
-        } else {
-            error_report("could not find a module for type '%s'", name);
-            exit(1);
-        }
-    }
-#endif
-    if (!oc) {
-        error_report("unknown type '%s'", name);
-        abort();
-    }
     return DEVICE(object_new(name));
 }
 
index 29155c646395aaf16c1e3422d144c7b25433c67d..9edc06d391fb024607fb2aac4366582e1ae18b71 100644 (file)
@@ -790,7 +790,7 @@ Object *object_new_with_class(ObjectClass *klass)
 
 Object *object_new(const char *typename)
 {
-    TypeImpl *ti = type_get_by_name_noload(typename);
+    TypeImpl *ti = type_get_or_load_by_name(typename, &error_fatal);
 
     return object_new_with_type(ti);
 }