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 06/10] qom: Add object_property_add_bool_ptr()
Date: Tue, 09 Jun 2026 20:18:05 -0300 [thread overview]
Message-ID: <87bjdj5mmq.fsf@suse.de> (raw)
In-Reply-To: <20260609172514.2037645-7-peterx@redhat.com>
Peter Xu <peterx@redhat.com> writes:
> Add a helper to set qom property via a bool pointer.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
> ---
> include/qom/object-property-ptr.h | 15 ++++++++++++
> qom/object-property-ptr.c | 39 +++++++++++++++++++++++++++++++
> 2 files changed, 54 insertions(+)
>
> diff --git a/include/qom/object-property-ptr.h b/include/qom/object-property-ptr.h
> index 6066c377fb..9cd8600094 100644
> --- a/include/qom/object-property-ptr.h
> +++ b/include/qom/object-property-ptr.h
> @@ -16,6 +16,21 @@ typedef enum {
> OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
> } ObjectPropertyFlags;
>
> +/**
> + * object_property_add_bool_ptr:
> + * @obj: the object to add a property to
> + * @name: the name of the property
> + * @v: pointer to value
> + * @flags: bitwise-or'd ObjectPropertyFlags
> + *
> + * Add a property of type 'bool' to the object.
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *
> +object_property_add_bool_ptr(Object *obj, const char *name, const bool *v,
> + ObjectPropertyFlags flags);
> +
> /**
> * object_property_add_uint8_ptr:
> * @obj: the object to add a property to
> diff --git a/qom/object-property-ptr.c b/qom/object-property-ptr.c
> index 02c01ed7f0..49f223da7b 100644
> --- a/qom/object-property-ptr.c
> +++ b/qom/object-property-ptr.c
> @@ -7,6 +7,26 @@
> #include "qom/object.h"
> #include "qapi/visitor.h"
>
> +static void property_get_bool_ptr(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> +{
> + bool value = *(bool *)opaque;
> + visit_type_bool(v, name, &value, errp);
> +}
> +
> +static void property_set_bool_ptr(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> +{
> + bool *field = opaque;
> + bool value;
> +
> + if (!visit_type_bool(v, name, &value, errp)) {
> + return;
> + }
> +
> + *field = value;
> +}
> +
> static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *name,
> void *opaque, Error **errp)
> {
> @@ -87,6 +107,25 @@ static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
> *field = value;
> }
>
> +ObjectProperty *
> +object_property_add_bool_ptr(Object *obj, const char *name,
> + const bool *v, ObjectPropertyFlags flags)
> +{
> + ObjectPropertyAccessor *getter = NULL;
> + ObjectPropertyAccessor *setter = NULL;
> +
> + if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> + getter = property_get_bool_ptr;
> + }
> +
> + if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> + setter = property_set_bool_ptr;
> + }
> +
> + return object_property_add(obj, name, "bool",
> + getter, setter, NULL, (void *)v);
> +}
> +
> ObjectProperty *
> object_property_add_uint8_ptr(Object *obj, const char *name,
> const uint8_t *v,
next prev parent reply other threads:[~2026-06-09 23:18 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 [this message]
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
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=87bjdj5mmq.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.