Commit ea9ce893 authored by Marc-André Lureau's avatar Marc-André Lureau
Browse files

hw: apply accel compat properties without touching globals



Instead of registering compat properties as globals, let's keep them
in their own array, to avoid mixing with user globals.

Introduce object_apply_global_props() function, to apply compatibility
properties from a GPtrArray.

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarIgor Mammedov <imammedo@redhat.com>
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Acked-by: default avatarEduardo Habkost <ehabkost@redhat.com>
parent e59dbbac
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -119,18 +119,6 @@ void configure_accelerator(MachineState *ms)
    }
}

void accel_register_compat_props(AccelState *accel)
{
    AccelClass *class = ACCEL_GET_CLASS(accel);
    GlobalProperty *prop = class->global_props;

    for (; prop && prop->driver; prop++) {
        /* Any compat_props must never cause error */
        prop->errp = &error_abort;
        qdev_prop_register_global(prop);
    }
}

void accel_setup_post(MachineState *ms)
{
    AccelState *accel = ms->accelerator;
+9 −0
Original line number Diff line number Diff line
@@ -972,6 +972,15 @@ static void device_initfn(Object *obj)

static void device_post_init(Object *obj)
{
    if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
        MachineState *m = MACHINE(qdev_get_machine());
        AccelClass *ac = ACCEL_GET_CLASS(m->accelerator);

        if (ac->compat_props) {
            object_apply_global_props(obj, ac->compat_props, &error_abort);
        }
    }

    qdev_prop_set_globals(DEVICE(obj));
}

+6 −3
Original line number Diff line number Diff line
@@ -174,18 +174,21 @@ static GlobalProperty xen_compat_props[] = {
        .driver = "migration",
        .property = "send-section-footer",
        .value = "off",
    },
    { /* end of list */ },
    }
};

static void xen_accel_class_init(ObjectClass *oc, void *data)
{
    AccelClass *ac = ACCEL_CLASS(oc);

    ac->name = "Xen";
    ac->init_machine = xen_init;
    ac->setup_post = xen_setup_post;
    ac->allowed = &xen_allowed;
    ac->global_props = xen_compat_props;
    ac->compat_props = g_ptr_array_new();

    compat_props_add(ac->compat_props,
                     xen_compat_props, G_N_ELEMENTS(xen_compat_props));
}

#define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
+10 −0
Original line number Diff line number Diff line
@@ -267,6 +267,16 @@ typedef struct GlobalProperty {
    Error **errp;
} GlobalProperty;

static inline void
compat_props_add(GPtrArray *arr,
                 GlobalProperty props[], size_t nelem)
{
    int i;
    for (i = 0; i < nelem; i++) {
        g_ptr_array_add(arr, (void *)&props[i]);
    }
}

/*** Board API.  This should go away once we have a machine config file.  ***/

DeviceState *qdev_create(BusState *bus, const char *name);
+3 −0
Original line number Diff line number Diff line
@@ -675,6 +675,9 @@ Object *object_new_with_propv(const char *typename,
                              Error **errp,
                              va_list vargs);

void object_apply_global_props(Object *obj, const GPtrArray *props,
                               Error **errp);

/**
 * object_set_props:
 * @obj: the object instance to set properties on
Loading