[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [PATCH for-3.2 v3 11/14] qom: teach interfaces to impleme
From: |
Igor Mammedov |
Subject: |
Re: [Qemu-arm] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init |
Date: |
Mon, 26 Nov 2018 14:46:40 +0100 |
On Wed, 7 Nov 2018 16:36:49 +0400
Marc-André Lureau <address@hidden> wrote:
> The following patches are going to implement post_init callbacks for
> settings properties. The interface post_init are called before the
> instance post_init, so the default interface behaviour can be
> overriden if necessary.
CCing ARM guys who touched arm_cpu_post_init() in the past,
pls provide feedback if suggested below approach is acceptable.
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> qom/object.c | 8 +++++++-
> tests/check-qom-interface.c | 23 +++++++++++++++++++++--
> 2 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index b1a7f70550..980eeb8283 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -290,7 +290,6 @@ static void type_initialize(TypeImpl *ti)
> assert(ti->instance_size == 0);
> assert(ti->abstract);
> assert(!ti->instance_init);
> - assert(!ti->instance_post_init);
> assert(!ti->instance_finalize);
> assert(!ti->num_interfaces);
> }
> @@ -363,6 +362,13 @@ static void object_init_with_type(Object *obj, TypeImpl
> *ti)
>
> static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> {
> + GSList *e;
> +
> + for (e = ti->class->interfaces; e; e = e->next) {
> + TypeImpl *itype = OBJECT_CLASS(e->data)->type;
> + object_post_init_with_type(obj, itype);
> + }
isn't arm_cpu_post_init() issue[1] still valid here?
1) http://patchwork.ozlabs.org/patch/969002/
probably cleanest/easiest way is to get rid of arm_cpu_post_init()
by calling it from leaf classes and then drop device_post_init()
along with switching to interface approach.
CCing guys who touched arm_cpu_post_init() in the past
> if (ti->instance_post_init) {
> ti->instance_post_init(obj);
> }
> diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
> index 2177f0dce5..cd2dd6dcee 100644
> --- a/tests/check-qom-interface.c
> +++ b/tests/check-qom-interface.c
> @@ -31,9 +31,27 @@ typedef struct TestIfClass {
> uint32_t test;
> } TestIfClass;
>
> +typedef struct DirectImpl {
> + Object parent_obj;
> +
> + bool if_post_init;
> +} DirectImpl;
> +
> +#define TYPE_DIRECT_IMPL "direct-impl"
> +#define DIRECT_IMPL(obj) \
> + OBJECT_CHECK(DirectImpl, (obj), TYPE_DIRECT_IMPL)
> +
> +static void test_if_post_init(Object *obj)
> +{
> + DirectImpl *d = DIRECT_IMPL(obj);
> +
> + d->if_post_init = true;
> +}
> +
> static const TypeInfo test_if_info = {
> .name = TYPE_TEST_IF,
> .parent = TYPE_INTERFACE,
> + .instance_post_init = test_if_post_init,
> .class_size = sizeof(TestIfClass),
> };
>
> @@ -47,11 +65,10 @@ static void test_class_init(ObjectClass *oc, void *data)
> tc->test = PATTERN;
> }
>
> -#define TYPE_DIRECT_IMPL "direct-impl"
> -
> static const TypeInfo direct_impl_info = {
> .name = TYPE_DIRECT_IMPL,
> .parent = TYPE_OBJECT,
> + .instance_size = sizeof(DirectImpl),
> .class_init = test_class_init,
> .interfaces = (InterfaceInfo[]) {
> { TYPE_TEST_IF },
> @@ -70,10 +87,12 @@ static void test_interface_impl(const char *type)
> {
> Object *obj = object_new(type);
> TestIf *iobj = TEST_IF(obj);
> + DirectImpl *d = DIRECT_IMPL(obj);
> TestIfClass *ioc = TEST_IF_GET_CLASS(iobj);
>
> g_assert(iobj);
> g_assert(ioc->test == PATTERN);
> + g_assert(d->if_post_init == true);
> object_unref(obj);
> }
>
- Re: [Qemu-arm] [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests, (continued)
- [Qemu-arm] [PATCH for-3.2 v3 04/14] accel: register global_props like machine globals, Marc-André Lureau, 2018/11/07
- [Qemu-arm] [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with global props, Marc-André Lureau, 2018/11/07
- [Qemu-arm] [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided, Marc-André Lureau, 2018/11/07
- [Qemu-arm] [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray, Marc-André Lureau, 2018/11/07
- [Qemu-arm] [PATCH for-3.2 v3 09/14] qdev-props: remove errp from GlobalProperty, Marc-André Lureau, 2018/11/07
- [Qemu-arm] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init, Marc-André Lureau, 2018/11/07
- Re: [Qemu-arm] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init,
Igor Mammedov <=
- [Qemu-arm] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2, Marc-André Lureau, 2018/11/07
- [Qemu-arm] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props(), Marc-André Lureau, 2018/11/07
- [Qemu-arm] [PATCH for-3.2 v3 12/14] machine: add compat-props interface, Marc-André Lureau, 2018/11/07
- [Qemu-arm] [PATCH for-3.2 v3 14/14] hostmem: use object id for memory region name with >= 3.1, Marc-André Lureau, 2018/11/07
- Re: [Qemu-arm] [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties, Igor Mammedov, 2018/11/26