From: Igor Mammedov <imammedo@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
Peter Maydell <peter.maydell@linaro.org>,
peter.crosthwaite@xilinx.com, antonynpavlov@gmail.com,
greg.bellows@linaro.org, wei@redhat.com, julian@codesourcery.com
Subject: Re: [Qemu-devel] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init
Date: Mon, 26 Nov 2018 14:46:40 +0100 [thread overview]
Message-ID: <20181126144640.361f21f0@redhat.com> (raw)
In-Reply-To: <20181107123652.23417-12-marcandre.lureau@redhat.com>
On Wed, 7 Nov 2018 16:36:49 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> 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 <marcandre.lureau@redhat.com>
> ---
> 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);
> }
>
next prev parent reply other threads:[~2018-11-26 13:46 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-07 12:36 [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 01/14] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
2018-11-20 15:33 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract Marc-André Lureau
2018-11-20 16:33 ` Igor Mammedov
2018-11-20 17:42 ` Eduardo Habkost
2018-11-20 18:54 ` Laszlo Ersek
2018-11-21 9:10 ` Igor Mammedov
2018-11-23 14:03 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 03/14] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
2018-11-20 16:39 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 04/14] accel: register global_props like machine globals Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-11-11 23:46 ` Philippe Mathieu-Daudé
2018-11-20 16:40 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with global props Marc-André Lureau
2018-11-23 14:02 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided Marc-André Lureau
2018-11-23 14:20 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray Marc-André Lureau
2018-11-23 14:26 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 09/14] qdev-props: remove errp from GlobalProperty Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props() Marc-André Lureau
2018-11-26 13:20 ` Igor Mammedov
2018-11-26 20:02 ` Marc-André Lureau
2018-11-27 14:12 ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init Marc-André Lureau
2018-11-26 13:46 ` Igor Mammedov [this message]
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 12/14] machine: add compat-props interface Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2 Marc-André Lureau
2018-11-07 15:49 ` Marc-André Lureau
2018-11-07 19:01 ` Eduardo Habkost
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 14/14] hostmem: use object id for memory region name with >= 3.1 Marc-André Lureau
2018-11-26 13:55 ` [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties Igor Mammedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181126144640.361f21f0@redhat.com \
--to=imammedo@redhat.com \
--cc=antonynpavlov@gmail.com \
--cc=greg.bellows@linaro.org \
--cc=julian@codesourcery.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wei@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).