All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, "Amit Shah" <amit@kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	dgilbert@redhat.com, "Igor Mammedov" <imammedo@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v2 07/10] qom/object: add set_globals flags
Date: Wed, 31 Oct 2018 17:23:51 -0300	[thread overview]
Message-ID: <20181031202351.GD30771@habkost.net> (raw)
In-Reply-To: <20181030150453.9344-8-marcandre.lureau@redhat.com>

On Tue, Oct 30, 2018 at 07:04:50PM +0400, Marc-André Lureau wrote:
> Guard against calling object_property_set_globals() for all objects,
> check that the class flag set_globals is set before. No need to guard
> in object_property_set_globals() anymore.
> 
> Only QDev & user-creatable objects have set_globals set at this point.
> 
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Should we squash this into patch 06/10?

The object_property_set_globals() hunk could be squashed into
patch 05/10.

> ---
>  include/qom/object.h    | 1 +
>  hw/core/qdev.c          | 1 +
>  qom/globals.c           | 5 -----
>  qom/object.c            | 5 ++++-
>  qom/object_interfaces.c | 7 +++++++
>  5 files changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index f0b0bf39cc..205099bc7e 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -400,6 +400,7 @@ struct ObjectClass
>      ObjectUnparent *unparent;
>  
>      GHashTable *properties;
> +    bool set_globals;
>  };
>  
>  /**
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6a25fa027c..78ce9a3095 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -1042,6 +1042,7 @@ static void device_class_init(ObjectClass *class, void *data)
>       */
>      dc->hotpluggable = true;
>      dc->user_creatable = true;
> +    class->set_globals = true;
>  }
>  
>  void device_class_set_parent_reset(DeviceClass *dc,
> diff --git a/qom/globals.c b/qom/globals.c
> index 8664baebe0..e94e6f2bf9 100644
> --- a/qom/globals.c
> +++ b/qom/globals.c
> @@ -18,11 +18,6 @@ void object_property_set_globals(Object *obj)
>      GList *l;
>      DeviceState *dev = (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE);
>  
> -    if (!dev && !IS_USER_CREATABLE(obj)) {
> -        /* only TYPE_DEVICE and TYPE_USER_CREATABLE support globals */
> -        return;
> -    }
> -
>      for (l = global_props; l; l = l->next) {
>          GlobalProperty *prop = l->data;
>          Error *err = NULL;
> diff --git a/qom/object.c b/qom/object.c
> index 7300878125..c18e630159 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -259,6 +259,7 @@ static void type_initialize_interface(TypeImpl *ti, TypeImpl *interface_type,
>  
>      ti->class->interfaces = g_slist_append(ti->class->interfaces,
>                                             iface_impl->class);
> +    ti->class->set_globals |= iface_impl->class->set_globals;
>  }
>  
>  static void object_property_free(gpointer data)
> @@ -391,7 +392,9 @@ static void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
>                                              NULL, object_property_free);
>      object_init_with_type(obj, type);
>      object_post_init_with_type(obj, type);
> -    object_property_set_globals(obj);
> +    if (object_get_class(obj)->set_globals) {
> +        object_property_set_globals(obj);
> +    }
>  }
>  
>  void object_initialize(void *data, size_t size, const char *typename)
> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> index db85d1eb75..67886845e7 100644
> --- a/qom/object_interfaces.c
> +++ b/qom/object_interfaces.c
> @@ -184,12 +184,19 @@ void user_creatable_cleanup(void)
>      object_unparent(object_get_objects_root());
>  }
>  
> +static void user_creatable_class_init(ObjectClass *klass, void *data)
> +{
> +    klass->set_globals = true;
> +}
> +
> +
>  static void register_types(void)
>  {
>      static const TypeInfo uc_interface_info = {
>          .name          = TYPE_USER_CREATABLE,
>          .parent        = TYPE_INTERFACE,
>          .class_size = sizeof(UserCreatableClass),
> +        .class_init = user_creatable_class_init,
>      };
>  
>      type_register_static(&uc_interface_info);
> -- 
> 2.19.0.271.gfe8321ec05
> 
> 

-- 
Eduardo

  reply	other threads:[~2018-10-31 20:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 15:04 [Qemu-devel] [PATCH v2 00/10] hostmem: use object "id" for memory region name with >= 3.1 Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 01/10] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
2018-11-01 11:03   ` Igor Mammedov
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 02/10] accel: register global_props like machine globals Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 03/10] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-10-31 20:22   ` Eduardo Habkost
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 04/10] qom/globals: move qdev globals to qom Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 05/10] qom/globals: generalize object_property_set_globals() Marc-André Lureau
2018-10-31 20:12   ` Eduardo Habkost
2018-11-01 10:18     ` Igor Mammedov
2018-11-01 15:27       ` Eduardo Habkost
2018-11-01 15:58         ` Igor Mammedov
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 06/10] qom/object: set globals when initializing object Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 07/10] qom/object: add set_globals flags Marc-André Lureau
2018-10-31 20:23   ` Eduardo Habkost [this message]
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 08/10] tests: add user-creatable test to test-qdev-global-props Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 09/10] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1 Marc-André Lureau
2018-10-31 20:14   ` Eduardo Habkost
2018-11-01 14:59   ` Igor Mammedov
2018-11-20 12:00     ` Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 10/10] hostmem: use object id for memory region name with >= 3.1 Marc-André Lureau
2018-10-31 20:27   ` Eduardo Habkost
2018-11-01 15:16     ` Igor Mammedov
2018-11-01 15:31       ` Eduardo Habkost
2018-10-31 14:41 ` [Qemu-devel] [PATCH v2 00/10] hostmem: use object "id" " no-reply
2018-10-31 14:43 ` no-reply
2018-11-03  3:37 ` no-reply
2018-11-03  3:39 ` no-reply

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=20181031202351.GD30771@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=afaerber@suse.de \
    --cc=amit@kernel.org \
    --cc=atar4qemu@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.