All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, "Cédric Le Goater" <clg@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@mailo.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Dr . David Alan Gilbert" <dave@treblig.org>,
	"Eric Blake" <eblake@redhat.com>,
	"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
	"Peter Xu" <peterx@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Sana Sharma" <sansshar@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Juraj Marcin" <jmarcin@redhat.com>,
	qemu-rust@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Mark Cave-Ayland" <mark.caveayland@nutanix.com>
Subject: Re: [PATCH v2 08/10] qom: Add object_property_add_*_ptr_def()
Date: Tue, 09 Jun 2026 20:21:18 -0300	[thread overview]
Message-ID: <875x3r5mhd.fsf@suse.de> (raw)
In-Reply-To: <20260609172514.2037645-9-peterx@redhat.com>

Peter Xu <peterx@redhat.com> writes:

> Add sister functions for existing pointer versions, to make it even easier
> to use by:
>
> - always make properties to be rw-able
> - allowing to specify default values
> - no retcode needed (assert on failure, always)
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  include/qom/object-property-ptr.h | 28 +++++++++++++
>  qom/object-property-ptr.c         | 67 +++++++++++++++++++++++++++++++
>  2 files changed, 95 insertions(+)
>
> diff --git a/include/qom/object-property-ptr.h b/include/qom/object-property-ptr.h
> index be467c64af..ecd6f7819b 100644
> --- a/include/qom/object-property-ptr.h
> +++ b/include/qom/object-property-ptr.h
> @@ -131,4 +131,32 @@ object_property_add_size_ptr(Object *obj, const char *name,
>                               const uint64_t *v,
>                               ObjectPropertyFlags flags);
>  
> +/*
> + * Below are sister helpers of above, except that:
> + *
> + * (1) nothing is returned
> + * (2) always make the property to be both readable and writeable
> + * (3) allow setting default value
> + *
> + * Please refer to the sister functions for the documentation.
> + */
> +void
> +object_property_add_bool_ptr_def(Object *obj, const char *name,
> +                                 const bool *v, bool def);
> +void
> +object_property_add_uint8_ptr_def(Object *obj, const char *name,
> +                                  const uint8_t *v, uint8_t def);
> +void
> +object_property_add_uint16_ptr_def(Object *obj, const char *name,
> +                                   const uint16_t *v, uint16_t def);
> +void
> +object_property_add_uint32_ptr_def(Object *obj, const char *name,
> +                                   const uint32_t *v, uint32_t def);
> +void
> +object_property_add_uint64_ptr_def(Object *obj, const char *name,
> +                                   const uint64_t *v, uint64_t def);
> +void
> +object_property_add_size_ptr_def(Object *obj, const char *name,
> +                                 const uint64_t *v, uint64_t def);
> +
>  #endif
> diff --git a/qom/object-property-ptr.c b/qom/object-property-ptr.c
> index 21ceb2510d..ae9081d2d8 100644
> --- a/qom/object-property-ptr.c
> +++ b/qom/object-property-ptr.c
> @@ -325,3 +325,70 @@ object_property_add_size_ptr(Object *obj, const char *name,
>      return object_property_add(obj, name, "size",
>                                 getter, setter, NULL, (void *)v);
>  }
> +
> +void
> +object_property_add_bool_ptr_def(Object *obj, const char *name,
> +                                 const bool *v, bool def)
> +{
> +    ObjectProperty *prop;
> +
> +    prop = object_property_add_bool_ptr(obj, name, v,
> +                                        OBJ_PROP_FLAG_READWRITE);
> +    object_property_set_default_bool(prop, def);
> +}
> +
> +
> +void
> +object_property_add_uint8_ptr_def(Object *obj, const char *name,
> +                                  const uint8_t *v, uint8_t def)
> +{
> +    ObjectProperty *prop;
> +
> +    prop = object_property_add_uint8_ptr(obj, name, v,
> +                                         OBJ_PROP_FLAG_READWRITE);
> +    object_property_set_default_uint(prop, def);
> +}
> +
> +void
> +object_property_add_uint16_ptr_def(Object *obj, const char *name,
> +                                   const uint16_t *v, uint16_t def)
> +{
> +    ObjectProperty *prop;
> +
> +    prop = object_property_add_uint16_ptr(obj, name, v,
> +                                          OBJ_PROP_FLAG_READWRITE);
> +    object_property_set_default_uint(prop, def);
> +}
> +
> +void
> +object_property_add_uint32_ptr_def(Object *obj, const char *name,
> +                                   const uint32_t *v, uint32_t def)
> +{
> +    ObjectProperty *prop;
> +
> +    prop = object_property_add_uint32_ptr(obj, name, v,
> +                                          OBJ_PROP_FLAG_READWRITE);
> +    object_property_set_default_uint(prop, def);
> +}
> +
> +void
> +object_property_add_uint64_ptr_def(Object *obj, const char *name,
> +                                   const uint64_t *v, uint64_t def)
> +{
> +    ObjectProperty *prop;
> +
> +    prop = object_property_add_uint64_ptr(obj, name, v,
> +                                          OBJ_PROP_FLAG_READWRITE);
> +    object_property_set_default_uint(prop, def);
> +}
> +
> +void
> +object_property_add_size_ptr_def(Object *obj, const char *name,
> +                                 const uint64_t *v, uint64_t def)
> +{
> +    ObjectProperty *prop;
> +
> +    prop = object_property_add_size_ptr(obj, name, v,
> +                                        OBJ_PROP_FLAG_READWRITE);
> +    object_property_set_default_uint(prop, def);
> +}

Reviewed-by: Fabiano Rosas <farosas@suse.de>


  reply	other threads:[~2026-06-09 23:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09 17:25 [PATCH v2 00/10] migration/qom: Remove TYPE_DEVICE dependency on migration object Peter Xu
2026-06-09 17:25 ` [PATCH v2 01/10] migration: Use OBJECT_DECLARE_SIMPLE_TYPE Peter Xu
2026-06-09 22:55   ` Fabiano Rosas
2026-06-09 17:25 ` [PATCH v2 02/10] qdev: Export global_props() Peter Xu
2026-06-09 22:55   ` Fabiano Rosas
2026-06-09 17:25 ` [PATCH v2 03/10] qdev: Introduce DEFINE_PROP_*_NODEFAULT for bool/uint32 Peter Xu
2026-06-09 17:25 ` [PATCH v2 04/10] hw/arm: Use nodefault version of qdev props when not needed Peter Xu
2026-06-09 17:25 ` [PATCH v2 05/10] qom: Create object-property-ptr.[ch] Peter Xu
2026-06-09 17:25 ` [PATCH v2 06/10] qom: Add object_property_add_bool_ptr() Peter Xu
2026-06-09 23:18   ` Fabiano Rosas
2026-06-09 17:25 ` [PATCH v2 07/10] qom: Add object_property_add_size_ptr() Peter Xu
2026-06-09 23:18   ` Fabiano Rosas
2026-06-09 17:25 ` [PATCH v2 08/10] qom: Add object_property_add_*_ptr_def() Peter Xu
2026-06-09 23:21   ` Fabiano Rosas [this message]
2026-06-09 17:25 ` [PATCH v2 09/10] qom: Allow default values for instance properties Peter Xu
2026-06-09 17:25 ` [PATCH v2 10/10] migration: Switch to TYPE_OBJECT with object properties Peter Xu
2026-06-09 22:54 ` [PATCH v2 00/10] migration/qom: Remove TYPE_DEVICE dependency on migration object Fabiano Rosas

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=875x3r5mhd.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=clg@redhat.com \
    --cc=dave@treblig.org \
    --cc=eblake@redhat.com \
    --cc=jmarcin@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.caveayland@nutanix.com \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=philmd@mailo.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-rust@nongnu.org \
    --cc=sansshar@redhat.com \
    --cc=vsementsov@yandex-team.ru \
    /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.