qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"John Snow" <jsnow@redhat.com>,
	"Stefan Berger" <stefanb@linux.ibm.com>
Subject: Re: [PATCH v4 26/32] qdev: Separate generic and device-specific property registration
Date: Tue, 15 Dec 2020 15:33:27 +0100	[thread overview]
Message-ID: <20201215153327.29f1664a@redhat.com> (raw)
In-Reply-To: <20201211220529.2290218-27-ehabkost@redhat.com>

On Fri, 11 Dec 2020 17:05:23 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> qdev_class_add_property() and qdev_property_add_static() will
> have code that's specific for device types.
> 
> object_class_property_add_field_static() and
> object_property_add_field() will be generic and part of the QOM
> field property API.  Note that the new functions have a `name`
> parameter because the plan is to eventually get rid of the
> Property.name field.
> 
> The declarations for the new functions are being added to
> qdev-properties-internal.h, but they will be moved to a QOM
> header later.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v2 -> v3:
> * Re-added array-based array registration function, named
>   as object_class_add_field_properties()
> * Renamed object_class_property_add_field() to
>   object_class_property_add_field_static(), to indicate that
>   the function expect the Property argument to have static life
>   time.
> * Keep all new functions as internal API by now,
>   until we decide what's going to be the preferred API for
>   registering class field properties.
> 
> Changes v1 -> v2:
> * Patch redone after changes in previous patches in the series
> * Rename new functions to object*_property_add_field()
> ---
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  hw/core/qdev-prop-internal.h | 42 ++++++++++++++++++++++++++++++++++++
>  hw/core/qdev-properties.c    | 37 ++++++++++++++++++++++++-------
>  2 files changed, 71 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h
> index d7b77844fe..6f17ddf271 100644
> --- a/hw/core/qdev-prop-internal.h
> +++ b/hw/core/qdev-prop-internal.h
> @@ -25,4 +25,46 @@ void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name,
>  void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name,
>                                void *opaque, Error **errp);
>  
> +/**
> + * object_property_add_field: Add a field property to an object instance
> + * @obj: object instance
> + * @name: property name
> + * @prop: property definition
> + *
> + * This function should not be used in new code.  Please add class properties
> + * instead, using object_class_add_field().
> + */
> +ObjectProperty *
> +object_property_add_field(Object *obj, const char *name,
> +                          Property *prop);
> +
> +/**
> + * object_class_property_add_field_static: Add a field property to object class
> + * @oc: object class
> + * @name: property name
> + * @prop: property definition
> + *
> + * Add a field property to an object class.  A field property is
> + * a property that will change a field at a specific offset of the
> + * object instance struct.
> + *
> + * *@prop must have static life time.
> + */
> +ObjectProperty *
> +object_class_property_add_field_static(ObjectClass *oc, const char *name,
> +                                       Property *prop);
> +
> +/**
> + * object_class_add_field_properties: Add field properties from array to a class
> + * @oc: object class
> + * @props: array of property definitions
> + *
> + * Register an array of field properties to a class, using
> + * object_class_property_add_field_static() for each array element.
> + *
> + * The array at @props must end with DEFINE_PROP_END_OF_LIST(), and
> + * must have static life time.
> + */
> +void object_class_add_field_properties(ObjectClass *oc, Property *props);
since it uses object_class_property_add_field_static() may be add _static suffix here as well?

> +
>  #endif
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index fcda0c8f4b..8436b60ec4 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -835,20 +835,21 @@ const PropertyInfo qdev_prop_link = {
>      .create = create_link_property,
>  };
>  
> -void qdev_property_add_static(DeviceState *dev, Property *prop)
> +ObjectProperty *
> +object_property_add_field(Object *obj, const char *name,
> +                          Property *prop)
>  {
> -    Object *obj = OBJECT(dev);
>      ObjectProperty *op;
>  
>      assert(!prop->info->create);
>  
> -    op = object_property_add(obj, prop->name, prop->info->name,
> +    op = object_property_add(obj, name, prop->info->name,
>                               field_prop_getter(prop->info),
>                               field_prop_setter(prop->info),
>                               prop->info->release,
>                               prop);
>  
> -    object_property_set_description(obj, prop->name,
> +    object_property_set_description(obj, name,
>                                      prop->info->description);
>  
>      if (prop->set_default) {
> @@ -857,12 +858,14 @@ void qdev_property_add_static(DeviceState *dev, Property *prop)
>              op->init(obj, op);
>          }
>      }
> +
> +    return op;
>  }
>  
> -static void qdev_class_add_property(DeviceClass *klass, const char *name,
> -                                    Property *prop)
> +ObjectProperty *
> +object_class_property_add_field_static(ObjectClass *oc, const char *name,
> +                                       Property *prop)
>  {
> -    ObjectClass *oc = OBJECT_CLASS(klass);
>      ObjectProperty *op;
>  
>      if (prop->info->create) {
> @@ -882,6 +885,22 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name,
>          object_class_property_set_description(oc, name,
>                                                prop->info->description);
>      }
> +    return op;
> +}
> +
> +void object_class_add_field_properties(ObjectClass *oc, Property *props)
> +{
> +    Property *prop;
> +
> +    for (prop = props; prop && prop->name; prop++) {
> +        object_class_property_add_field_static(oc, prop->name, prop);
> +    }
> +}
> +
> +
> +void qdev_property_add_static(DeviceState *dev, Property *prop)
> +{
> +    object_property_add_field(OBJECT(dev), prop->name, prop);
>  }
>  
>  /**
> @@ -932,13 +951,15 @@ static void qdev_class_add_legacy_property(DeviceClass *dc, Property *prop)
>  
>  void device_class_set_props(DeviceClass *dc, Property *props)
>  {
> +    ObjectClass *oc = OBJECT_CLASS(dc);
>      Property *prop;
>  
>      dc->props_ = props;
>      for (prop = props; prop && prop->name; prop++) {
>          qdev_class_add_legacy_property(dc, prop);
> -        qdev_class_add_property(dc, prop->name, prop);
>      }
> +
> +    object_class_add_field_properties(oc, props);
>  }
>  
>  void qdev_alias_all_properties(DeviceState *target, Object *source)



  reply	other threads:[~2020-12-15 14:36 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 22:04 [PATCH v4 00/32] qdev property code cleanup Eduardo Habkost
2020-12-11 22:04 ` [PATCH v4 01/32] cs4231: Get rid of empty property array Eduardo Habkost
2020-12-15  8:22   ` Gerd Hoffmann
2020-12-11 22:04 ` [PATCH v4 02/32] cpu: Move cpu_common_props to hw/core/cpu.c Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 03/32] qdev: Move property code to qdev-properties.[ch] Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 04/32] qdev: Check dev->realized at set_size() Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 05/32] sparc: Check dev->realized at sparc_set_nwindows() Eduardo Habkost
2020-12-15 11:45   ` Mark Cave-Ayland
2020-12-11 22:05 ` [PATCH v4 06/32] qdev: Don't use dev->id on set_size32() error message Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 07/32] qdev: Make PropertyInfo.print method get Object* argument Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 08/32] qdev: Make bit_prop_set() " Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 09/32] qdev: Make qdev_get_prop_ptr() get Object* arg Eduardo Habkost
2020-12-14  7:46   ` Paul Durrant
2020-12-11 22:05 ` [PATCH v4 10/32] qdev: Make qdev_find_global_prop() get Object* argument Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 11/32] qdev: Make check_prop_still_unset() " Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 12/32] qdev: Make error_set_from_qdev_prop_error() " Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 13/32] qdev: Make qdev_propinfo_get_uint16() static Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 14/32] qdev: Move UUID property to qdev-properties-system.c Eduardo Habkost
2020-12-14 14:18   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 15/32] qdev: Move softmmu properties to qdev-properties-system.h Eduardo Habkost
2020-12-14 14:25   ` Igor Mammedov
2020-12-14 17:40     ` Eduardo Habkost
2020-12-15 14:40   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 16/32] qdev: Reuse DEFINE_PROP in all DEFINE_PROP_* macros Eduardo Habkost
2020-12-14 14:32   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 17/32] sparc: Use DEFINE_PROP for nwindows property Eduardo Habkost
2020-12-14 14:42   ` Igor Mammedov
2020-12-14 17:30     ` Eduardo Habkost
2020-12-15 14:39       ` Igor Mammedov
2020-12-15 11:52   ` Mark Cave-Ayland
2020-12-11 22:05 ` [PATCH v4 18/32] qdev: Get just property name at error_set_from_qdev_prop_error() Eduardo Habkost
2020-12-14 10:41   ` Cornelia Huck
2020-12-14 14:44   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 19/32] qdev: Avoid using prop->name unnecessarily Eduardo Habkost
2020-12-14 14:45   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 20/32] qdev: Add name parameter to qdev_class_add_property() Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 21/32] qdev: Add name argument to PropertyInfo.create method Eduardo Habkost
2020-12-14 14:47   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 22/32] qdev: Wrap getters and setters in separate helpers Eduardo Habkost
2020-12-15 14:42   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 23/32] qdev: Move dev->realized check to qdev_property_set() Eduardo Habkost
2020-12-14  7:46   ` Paul Durrant
2020-12-14 10:46   ` Cornelia Huck
2020-12-14 14:55   ` Igor Mammedov
2020-12-14 17:24     ` Eduardo Habkost
2020-12-15 14:24       ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 24/32] qdev: Make PropertyInfo.create return ObjectProperty* Eduardo Habkost
2020-12-14 14:57   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 25/32] qdev: Make qdev_class_add_property() more flexible Eduardo Habkost
2020-12-14 15:00   ` Igor Mammedov
2020-12-14 18:28     ` Eduardo Habkost
2020-12-15 14:25       ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 26/32] qdev: Separate generic and device-specific property registration Eduardo Habkost
2020-12-15 14:33   ` Igor Mammedov [this message]
2020-12-11 22:05 ` [PATCH v4 27/32] qdev: Rename qdev_propinfo_* to field_prop_* Eduardo Habkost
2020-12-15 14:35   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 28/32] qdev: Move qdev_prop_tpm declaration to tpm_prop.h Eduardo Habkost
2020-12-15 14:36   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 29/32] qdev: Rename qdev_prop_* to prop_info_* Eduardo Habkost
2020-12-11 22:05 ` [PATCH v4 30/32] qdev: Rename qdev_get_prop_ptr() to object_field_prop_ptr() Eduardo Habkost
2020-12-14  7:47   ` Paul Durrant
2020-12-14 10:56   ` Cornelia Huck
2020-12-14 15:13   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 31/32] qdev: Avoid unnecessary DeviceState* variable at set_prop_arraylen() Eduardo Habkost
2020-12-14 15:11   ` Igor Mammedov
2020-12-11 22:05 ` [PATCH v4 32/32] tests: Add unit test for qdev array properties Eduardo Habkost
2020-12-14 19:42 ` [PATCH v4 00/32] qdev property code cleanup Eduardo Habkost
2020-12-15 15:40   ` Eduardo Habkost
2020-12-15 16:57     ` Eduardo Habkost

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=20201215153327.29f1664a@redhat.com \
    --to=imammedo@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.ibm.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).