qdev: device module support

Hook module loading into the places where we
need it when building devices as modules.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-4-kraxel@redhat.com
This commit is contained in:
Gerd Hoffmann 2020-06-24 15:10:38 +02:00
parent 0f8198f1b2
commit 7ab6e7fcce
4 changed files with 11 additions and 7 deletions

View file

@ -137,6 +137,9 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
*/
DeviceState *qdev_new(const char *name)
{
if (!object_class_by_name(name)) {
module_load_qom_one(name);
}
return DEVICE(object_new(name));
}
@ -147,10 +150,9 @@ DeviceState *qdev_new(const char *name)
*/
DeviceState *qdev_try_new(const char *name)
{
if (!object_class_by_name(name)) {
if (!module_object_class_by_name(name)) {
return NULL;
}
return DEVICE(object_new(name));
}