qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 07/10] qom/object: add set_globals flags


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH v2 07/10] qom/object: add set_globals flags
Date: Wed, 31 Oct 2018 17:23:51 -0300
User-agent: Mutt/1.9.2 (2017-12-15)

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 <address@hidden>
> Signed-off-by: Marc-André Lureau <address@hidden>

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 via email to

[Prev in Thread] Current Thread [Next in Thread]