From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Cc: mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com,
philmd@mailo.com, aurelien@aurel32.net, peter.maydell@linaro.org,
richard.henderson@linaro.org, marcandre.lureau@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: Re: [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr()
Date: Mon, 24 Aug 2026 13:53:22 +0100 [thread overview]
Message-ID: <aow-wlxrMnOS8Vqv@redhat.com> (raw)
In-Reply-To: <20260821111550.276011-11-mark.caveayland@nutanix.com>
On Fri, Aug 21, 2026 at 12:14:22PM +0100, Mark Cave-Ayland wrote:
> This adds a class property that references a bool within the object instance
> and is intended to be used as a replacement for object_class_property_add_bool()
> where possible.
>
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/qom/object.h | 18 ++++++++++++++++++
> qom/object.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 61 insertions(+)
>
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 8dead29284..de37016ba8 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -2017,6 +2017,24 @@ typedef enum {
> OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
> } ObjectPropertyFlags;
>
> +/**
> + * object_class_property_add_bool_ptr:
> + * @klass: the object class to add a property to
> + * @name: the name of the property
> + * @offset: the offset from the object instance where the bool value is
> + * stored
> + * @flags: bitwise-or'd ObjectPropertyFlags
> + *
> + * Add an boolean property in memory. This function will add a
> + * property of type 'bool'.
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *object_class_property_add_bool_ptr(ObjectClass *klass,
> + const char *name,
> + ptrdiff_t offset,
> + ObjectPropertyFlags flags);
> +
> /**
> * object_property_add_uint8_ptr:
> * @obj: the object to add a property to
> diff --git a/qom/object.c b/qom/object.c
> index f91764aaa7..635eeeac77 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -2750,6 +2750,49 @@ DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
> #undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
>
>
> +static void property_class_get_bool_ptr(Object *obj, Visitor *v,
> + const char *name,
> + void *opaque, Error **errp)
> +{
> + bool value = *(bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
> +
> + visit_type_bool(v, name, &value, errp);
> +}
> +
> +static void property_class_set_bool_ptr(Object *obj, Visitor *v,
> + const char *name,
> + void *opaque, Error **errp)
> +{
> + bool *field = (bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
> + bool value;
> +
> + if (!visit_type_bool(v, name, &value, errp)) {
> + return;
> + }
> +
> + *field = value;
> +}
Am I missing the reason why we can't use
DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(bool)
? If so, could that be mentioned in the commit message.
> +
> +ObjectProperty *
> +object_class_property_add_bool_ptr(ObjectClass *klass, const char *name,
> + ptrdiff_t offset,
> + ObjectPropertyFlags flags)
> +{
> + ObjectPropertyAccessor *getter = NULL;
> + ObjectPropertyAccessor *setter = NULL;
> +
> + if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> + getter = property_class_get_bool_ptr;
> + }
> +
> + if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> + setter = property_class_set_bool_ptr;
> + }
> +
> + return object_class_property_add(klass, name, "bool",
> + getter, setter, NULL, (void *)offset);
> +}
> +
> ObjectProperty *
> object_property_add_uint8_ptr(Object *obj, const char *name,
> const uint8_t *v,
> --
> 2.43.0
>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-08-24 12:53 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
2026-08-21 11:14 ` [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro Mark Cave-Ayland
2026-08-24 12:43 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro Mark Cave-Ayland
2026-08-24 12:44 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro Mark Cave-Ayland
2026-08-24 12:44 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
2026-08-24 12:45 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
2026-08-24 12:46 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
2026-08-24 12:47 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
2026-08-24 12:48 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
2026-08-24 12:48 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property Mark Cave-Ayland
2026-08-24 12:50 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr() Mark Cave-Ayland
2026-08-24 12:53 ` Daniel P. Berrangé [this message]
2026-08-24 13:39 ` Mark Cave-Ayland
2026-08-24 13:57 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
2026-08-24 12:59 ` Daniel P. Berrangé
2026-08-24 13:41 ` Mark Cave-Ayland
2026-08-21 11:14 ` [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
2026-08-24 13:00 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props Mark Cave-Ayland
2026-08-24 13:01 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
2026-08-24 13:04 ` Daniel P. Berrangé
2026-08-24 13:47 ` Mark Cave-Ayland
2026-08-25 7:17 ` Markus Armbruster
2026-08-25 12:53 ` Mark Cave-Ayland
2026-08-25 13:29 ` Markus Armbruster
2026-08-21 11:14 ` [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties Mark Cave-Ayland
2026-08-24 13:05 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop Mark Cave-Ayland
2026-08-24 13:06 ` Daniel P. Berrangé
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=aow-wlxrMnOS8Vqv@redhat.com \
--to=berrange@redhat.com \
--cc=anisinha@redhat.com \
--cc=aurelien@aurel32.net \
--cc=imammedo@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.caveayland@nutanix.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@mailo.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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.