diff options
author | Igor Mammedov <imammedo@redhat.com> | 2013-04-11 16:51:56 +0200 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-04-16 01:19:46 +0200 |
commit | a7ddba527c0b9dd32dfa7e35fa41701f990a3db4 (patch) | |
tree | bd9b2e223e127d3d7f5ec3e4c9cfc74e56ca2c9f /hw/core | |
parent | 3f24a58fa7dacd82cb72393367be207b0dab16b4 (diff) |
qdev: Set device's parent before calling realize() down inheritance chain
Currently device_set_realized() sets parent only after device was realized,
but qdev_device_add() sets it before device is realized.
Make behavior consistent and alter device_set_realized() to behave like
qdev_device_add().
It will allow to set link<> properties in realize() method in classes
inherited from DEVICE.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/qdev.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index bab4ed7bf7..4eb01345df 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -684,10 +684,6 @@ static void device_set_realized(Object *obj, bool value, Error **err) Error *local_err = NULL; if (value && !dev->realized) { - if (dc->realize) { - dc->realize(dev, &local_err); - } - if (!obj->parent && local_err == NULL) { static int unattached_count; gchar *name = g_strdup_printf("device[%d]", unattached_count++); @@ -698,6 +694,10 @@ static void device_set_realized(Object *obj, bool value, Error **err) g_free(name); } + if (dc->realize) { + dc->realize(dev, &local_err); + } + if (qdev_get_vmsd(dev) && local_err == NULL) { vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev, dev->instance_id_alias, |