[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [Qemu-devel] [PATCH for-3.2 v5 07/19] hw: apply accel compat properties without touching globals
On Wed, 12 Dec 2018 16:00:06 +0400 Marc-André Lureau <marcandre.lureau@xxxxxxxxx> wrote: > Hi > On Mon, Dec 10, 2018 at 8:55 PM Igor Mammedov <imammedo@xxxxxxxxxx> wrote: > > > > On Mon, 10 Dec 2018 17:45:22 +0100 > > Igor Mammedov <imammedo@xxxxxxxxxx> wrote: > > > > > On Tue, 4 Dec 2018 18:20:11 +0400 > > > Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> wrote: > > > > > > > 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: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> > > > > --- > > > > include/hw/qdev-core.h | 10 ++++++++++ > > > > include/qom/object.h | 3 +++ > > > > include/sysemu/accel.h | 4 +--- > > > > accel/accel.c | 12 ------------ > > > > hw/core/qdev.c | 9 +++++++++ > > > > hw/xen/xen-common.c | 9 ++++++--- > > > > qom/object.c | 25 +++++++++++++++++++++++++ > > > > vl.c | 1 - > > > > 8 files changed, 54 insertions(+), 19 deletions(-) > > > > > > > [...] > > > > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c > > > > index 6ec14c73ca..4532aa8632 100644 > > > > --- a/hw/xen/xen-common.c > > > > +++ b/hw/xen/xen-common.c > > > > @@ -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(); > > > where is matching free for that? > > can we at least annotate it somehow so that valgrind won't complain about > > this leak? > > If you check my commits on qemu, you should see that I do care (too > much?) about leaks :) > > In this case though, I don't see valgrind or asan complaining, I guess > it's still a reachable reference. > Do you think a FIXME comment would be helpful? I've looked at other cases were we leak, and well we leak a lot so it's probably futile exercise. But the comment won't hurt and will work as remainder. > (/me wish we had a proper object system, GObject, but that ship as > long sailed..) > > > > > > > > > > + > > > > + compat_props_add(ac->compat_props, > > > > + xen_compat_props, G_N_ELEMENTS(xen_compat_props)); > > > > } > > > > > > > > #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen") > > > > diff --git a/qom/object.c b/qom/object.c > > > > index 17921c0a71..dbdab0aead 100644 > > > > --- a/qom/object.c > > > > +++ b/qom/object.c > > > > @@ -370,6 +370,31 @@ static void object_post_init_with_type(Object > > > > *obj, TypeImpl *ti) > > > > } > > > > } > > > > > > > > +void object_apply_global_props(Object *obj, const GPtrArray *props, > > > > Error **errp) > > > > +{ > > > > + Error *err = NULL; > > > > + int i; > > > > + > > > > + if (!props) { > > > > + return; > > > > + } > > > > + > > > > + for (i = 0; i < props->len; i++) { > > > > + GlobalProperty *p = g_ptr_array_index(props, i); > > > > + > > > > + if (object_dynamic_cast(obj, p->driver) == NULL) { > > > > + continue; > > > > + } > > > > + p->used = true; > > > > + object_property_parse(obj, p->value, p->property, &err); > > > > + if (err != NULL) { > > > > + error_prepend(&err, "can't apply global %s.%s=%s: ", > > > > + p->driver, p->property, p->value); > > > > + error_propagate(errp, err); > > > > + } > > > > + } > > > > +} > > > > + > > > > static void object_initialize_with_type(void *data, size_t size, > > > > TypeImpl *type) > > > > { > > > > Object *obj = data; > > > > diff --git a/vl.c b/vl.c > > > > index a5ae5f23d2..88ba658572 100644 > > > > --- a/vl.c > > > > +++ b/vl.c > > > > @@ -2968,7 +2968,6 @@ static void user_register_global_props(void) > > > > */ > > > > static void register_global_properties(MachineState *ms) > > > > { > > > > - accel_register_compat_props(ms->accelerator); > > > > machine_register_compat_props(ms); > > > > user_register_global_props(); > > > > } > > > > > > > > > > > > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |