qdev: make a separate helper function to apply compat properties

This will allow to apply compat properties on other objects than QDev easily.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
Marc-André Lureau 2018-12-02 01:23:27 +04:00
parent a310e653ce
commit 1c3994f6d2
2 changed files with 7 additions and 1 deletions

View File

@ -970,7 +970,7 @@ static void device_initfn(Object *obj)
QLIST_INIT(&dev->gpios);
}
static void device_post_init(Object *obj)
void object_apply_compat_props(Object *obj)
{
if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
MachineState *m = MACHINE(qdev_get_machine());
@ -982,7 +982,11 @@ static void device_post_init(Object *obj)
}
object_apply_global_props(obj, mc->compat_props, &error_abort);
}
}
static void device_post_init(Object *obj)
{
object_apply_compat_props(obj);
qdev_prop_set_globals(DEVICE(obj));
}

View File

@ -422,6 +422,8 @@ const char *qdev_fw_name(DeviceState *dev);
Object *qdev_get_machine(void);
void object_apply_compat_props(Object *obj);
/* FIXME: make this a link<> */
void qdev_set_parent_bus(DeviceState *dev, BusState *bus);