mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
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>
This commit is contained in:
parent
fa386d989d
commit
b66bbee39f
9 changed files with 148 additions and 93 deletions
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue