diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2018-12-01 23:44:11 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-01-07 16:18:41 +0400 |
commit | b66bbee39f6deb28f0645760c536cbf2189a0687 (patch) | |
tree | dd227120080b44e0a4dbdcb78c296e48de7b11a9 /hw/core | |
parent | fa386d989d0bec0abdcd1a883853071928adcced (diff) |
hw: apply machine compat properties without touching globals
Similarly to accel properties, move compat properties out of globals
registration, and apply the machine compat properties during
device_post_init().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/machine.c | 19 | ||||
-rw-r--r-- | hw/core/qdev.c | 2 |
2 files changed, 3 insertions, 18 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c index 4439ea663f..bd644c976b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -647,6 +647,7 @@ static void machine_class_base_init(ObjectClass *oc, void *data) assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX)); mc->name = g_strndup(cname, strlen(cname) - strlen(TYPE_MACHINE_SUFFIX)); + mc->compat_props = g_ptr_array_new(); } } @@ -836,24 +837,6 @@ void machine_run_board_init(MachineState *machine) machine_class->init(machine); } -void machine_register_compat_props(MachineState *machine) -{ - MachineClass *mc = MACHINE_GET_CLASS(machine); - int i; - GlobalProperty *p; - - if (!mc->compat_props) { - return; - } - - for (i = 0; i < mc->compat_props->len; i++) { - p = g_array_index(mc->compat_props, GlobalProperty *, i); - /* Machine compat_props must never cause errors: */ - p->errp = &error_abort; - qdev_prop_register_global(p); - } -} - static const TypeInfo machine_info = { .name = TYPE_MACHINE, .parent = TYPE_OBJECT, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 53b507164f..d510340bac 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -974,11 +974,13 @@ static void device_post_init(Object *obj) { if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) { MachineState *m = MACHINE(qdev_get_machine()); + MachineClass *mc = MACHINE_GET_CLASS(m); AccelClass *ac = ACCEL_GET_CLASS(m->accelerator); if (ac->compat_props) { object_apply_global_props(obj, ac->compat_props, &error_abort); } + object_apply_global_props(obj, mc->compat_props, &error_abort); } qdev_prop_set_globals(DEVICE(obj)); |