mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qdev: Set globals in instance_post_init function
This way, properties registered in the instance_init function of child classes will be handled properly by qdev_prop_set_globals(), too. Includes a unit test for the new functionality. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
8231c2dd22
commit
99a0b03650
2 changed files with 83 additions and 1 deletions
|
@ -752,7 +752,6 @@ static void device_initfn(Object *obj)
|
|||
}
|
||||
class = object_class_get_parent(class);
|
||||
} while (class != object_class_by_name(TYPE_DEVICE));
|
||||
qdev_prop_set_globals(dev, &err);
|
||||
if (err != NULL) {
|
||||
qerror_report_err(err);
|
||||
error_free(err);
|
||||
|
@ -764,6 +763,15 @@ static void device_initfn(Object *obj)
|
|||
assert_no_error(err);
|
||||
}
|
||||
|
||||
static void device_post_init(Object *obj)
|
||||
{
|
||||
DeviceState *dev = DEVICE(obj);
|
||||
Error *err = NULL;
|
||||
|
||||
qdev_prop_set_globals(dev, &err);
|
||||
assert_no_error(err);
|
||||
}
|
||||
|
||||
/* Unlink device from bus and free the structure. */
|
||||
static void device_finalize(Object *obj)
|
||||
{
|
||||
|
@ -853,6 +861,7 @@ static const TypeInfo device_type_info = {
|
|||
.parent = TYPE_OBJECT,
|
||||
.instance_size = sizeof(DeviceState),
|
||||
.instance_init = device_initfn,
|
||||
.instance_post_init = device_post_init,
|
||||
.instance_finalize = device_finalize,
|
||||
.class_base_init = device_class_base_init,
|
||||
.class_init = device_class_init,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue