Re: [PATCH v2 05/10] qom: Create object-property-ptr.[ch]

Mark Cave-Ayland <[email protected]> Thu, 11 Jun 2026 13:54:54 +0100
Newsgroups org.nongnu.qemu-rust,org.nongnu.qemu-arm,org.nongnu.qemu-devel
Message-ID <[email protected]>
On 09/06/2026 18:25, Peter Xu wrote:

> Create object-property-ptr.[ch] files to include all the helpers for
> object_property_add*_ptr().
> 
> These set of helpers are handy because they look extremely familiar with
> qdev-properties, allowing the caller to provide a pointer and it will
> manage all the setters and getters.
> 
> The follow up patches may introduce more of such helpers.  Since object.c
> has been already too big, split that part out.
> 
> No functional change intended.
> 
> Signed-off-by: Peter Xu <[email protected]>
> ---
>   include/qom/object-property-ptr.h | 103 +++++++++++++
>   include/qom/object.h              |  99 +-----------
>   qom/object-property-ptr.c         | 248 ++++++++++++++++++++++++++++++
>   qom/object.c                      | 240 -----------------------------
>   qom/meson.build                   |   1 +
>   5 files changed, 358 insertions(+), 333 deletions(-)
>   create mode 100644 include/qom/object-property-ptr.h
>   create mode 100644 qom/object-property-ptr.c
> 
> diff --git a/include/qom/object-property-ptr.h b/include/qom/object-property-ptr.h
> new file mode 100644
> index 0000000000..6066c377fb
> --- /dev/null
> +++ b/include/qom/object-property-ptr.h
> @@ -0,0 +1,103 @@
> +/*
> + * Object property helpers to operate on a pointer.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef QEMU_OBJECT_PROPERTY_PTR_H
> +#define QEMU_OBJECT_PROPERTY_PTR_H
> +
> +typedef enum {
> +    /* Automatically add a getter to the property */
> +    OBJ_PROP_FLAG_READ = 1 << 0,
> +    /* Automatically add a setter to the property */
> +    OBJ_PROP_FLAG_WRITE = 1 << 1,
> +    /* Automatically add a getter and a setter to the property */
> +    OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
> +} ObjectPropertyFlags;
> +
> +/**
> + * object_property_add_uint8_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 an integer property in memory.  This function will add a
> + * property of type 'uint8'.
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
> +                                              const uint8_t *v,
> +                                              ObjectPropertyFlags flags);
> +
> +ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
> +                                         const char *name,
> +                                         const uint8_t *v,
> +                                         ObjectPropertyFlags flags);
> +
> +/**
> + * object_property_add_uint16_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 an integer property in memory.  This function will add a
> + * property of type 'uint16'.
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
> +                                    const uint16_t *v,
> +                                    ObjectPropertyFlags flags);
> +
> +ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
> +                                          const char *name,
> +                                          const uint16_t *v,
> +                                          ObjectPropertyFlags flags);
> +
> +/**
> + * object_property_add_uint32_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 an integer property in memory.  This function will add a
> + * property of type 'uint32'.
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
> +                                    const uint32_t *v,
> +                                    ObjectPropertyFlags flags);
> +
> +ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
> +                                          const char *name,
> +                                          const uint32_t *v,
> +                                          ObjectPropertyFlags flags);
> +
> +/**
> + * object_property_add_uint64_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 an integer property in memory.  This function will add a
> + * property of type 'uint64'.
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
> +                                    const uint64_t *v,
> +                                    ObjectPropertyFlags flags);
> +
> +ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
> +                                          const char *name,
> +                                          const uint64_t *v,
> +                                          ObjectPropertyFlags flags);
> +
> +#endif
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 11f55613fc..6ea569d580 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1931,99 +1931,6 @@ ObjectProperty *object_class_property_add_tm(ObjectClass *klass,
>                               const char *name,
>                               void (*get)(Object *, struct tm *, Error **));
>   
> -typedef enum {
> -    /* Automatically add a getter to the property */
> -    OBJ_PROP_FLAG_READ = 1 << 0,
> -    /* Automatically add a setter to the property */
> -    OBJ_PROP_FLAG_WRITE = 1 << 1,
> -    /* Automatically add a getter and a setter to the property */
> -    OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
> -} ObjectPropertyFlags;
> -
> -/**
> - * object_property_add_uint8_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 an integer property in memory.  This function will add a
> - * property of type 'uint8'.
> - *
> - * Returns: The newly added property on success, or %NULL on failure.
> - */
> -ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
> -                                              const uint8_t *v,
> -                                              ObjectPropertyFlags flags);
> -
> -ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
> -                                         const char *name,
> -                                         const uint8_t *v,
> -                                         ObjectPropertyFlags flags);
> -
> -/**
> - * object_property_add_uint16_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 an integer property in memory.  This function will add a
> - * property of type 'uint16'.
> - *
> - * Returns: The newly added property on success, or %NULL on failure.
> - */
> -ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
> -                                    const uint16_t *v,
> -                                    ObjectPropertyFlags flags);
> -
> -ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
> -                                          const char *name,
> -                                          const uint16_t *v,
> -                                          ObjectPropertyFlags flags);
> -
> -/**
> - * object_property_add_uint32_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 an integer property in memory.  This function will add a
> - * property of type 'uint32'.
> - *
> - * Returns: The newly added property on success, or %NULL on failure.
> - */
> -ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
> -                                    const uint32_t *v,
> -                                    ObjectPropertyFlags flags);
> -
> -ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
> -                                          const char *name,
> -                                          const uint32_t *v,
> -                                          ObjectPropertyFlags flags);
> -
> -/**
> - * object_property_add_uint64_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 an integer property in memory.  This function will add a
> - * property of type 'uint64'.
> - *
> - * Returns: The newly added property on success, or %NULL on failure.
> - */
> -ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
> -                                    const uint64_t *v,
> -                                    ObjectPropertyFlags flags);
> -
> -ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
> -                                          const char *name,
> -                                          const uint64_t *v,
> -                                          ObjectPropertyFlags flags);
> -
>   /**
>    * object_property_add_alias:
>    * @obj: the object to add a property to
> @@ -2141,4 +2048,10 @@ char *object_property_help(const char *name, const char *type,
>   
>   G_DEFINE_AUTOPTR_CLEANUP_FUNC(Object, object_unref)
>   
> +/*
> + * Object property ptr helpers cannot be included at the beginning of the
> + * file, because it depends on QOM definitions in current header.
> + */
> +#include "qom/object-property-ptr.h"

I wonder if possibly we might want to let the caller include the extra 
header? But I don't feel too strongly either way.

>   #endif
> diff --git a/qom/object-property-ptr.c b/qom/object-property-ptr.c
> new file mode 100644
> index 0000000000..02c01ed7f0
> --- /dev/null
> +++ b/qom/object-property-ptr.c
> @@ -0,0 +1,248 @@
> +/*
> + * Object property helpers to operate on a pointer.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +#include "qemu/osdep.h"
> +#include "qom/object.h"
> +#include "qapi/visitor.h"
> +
> +static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *name,
> +                                   void *opaque, Error **errp)
> +{
> +    uint8_t value = *(uint8_t *)opaque;
> +    visit_type_uint8(v, name, &value, errp);
> +}
> +
> +static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name,
> +                                   void *opaque, Error **errp)
> +{
> +    uint8_t *field = opaque;
> +    uint8_t value;
> +
> +    if (!visit_type_uint8(v, name, &value, errp)) {
> +        return;
> +    }
> +
> +    *field = value;
> +}
> +
> +static void property_get_uint16_ptr(Object *obj, Visitor *v, const char *name,
> +                                    void *opaque, Error **errp)
> +{
> +    uint16_t value = *(uint16_t *)opaque;
> +    visit_type_uint16(v, name, &value, errp);
> +}
> +
> +static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name,
> +                                    void *opaque, Error **errp)
> +{
> +    uint16_t *field = opaque;
> +    uint16_t value;
> +
> +    if (!visit_type_uint16(v, name, &value, errp)) {
> +        return;
> +    }
> +
> +    *field = value;
> +}
> +
> +static void property_get_uint32_ptr(Object *obj, Visitor *v, const char *name,
> +                                    void *opaque, Error **errp)
> +{
> +    uint32_t value = *(uint32_t *)opaque;
> +    visit_type_uint32(v, name, &value, errp);
> +}
> +
> +static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name,
> +                                    void *opaque, Error **errp)
> +{
> +    uint32_t *field = opaque;
> +    uint32_t value;
> +
> +    if (!visit_type_uint32(v, name, &value, errp)) {
> +        return;
> +    }
> +
> +    *field = value;
> +}
> +
> +static void property_get_uint64_ptr(Object *obj, Visitor *v, const char *name,
> +                                    void *opaque, Error **errp)
> +{
> +    uint64_t value = *(uint64_t *)opaque;
> +    visit_type_uint64(v, name, &value, errp);
> +}
> +
> +static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
> +                                    void *opaque, Error **errp)
> +{
> +    uint64_t *field = opaque;
> +    uint64_t value;
> +
> +    if (!visit_type_uint64(v, name, &value, errp)) {
> +        return;
> +    }
> +
> +    *field = value;
> +}
> +
> +ObjectProperty *
> +object_property_add_uint8_ptr(Object *obj, const char *name,
> +                              const uint8_t *v,
> +                              ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_get_uint8_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_set_uint8_ptr;
> +    }
> +
> +    return object_property_add(obj, name, "uint8",
> +                               getter, setter, NULL, (void *)v);
> +}
> +
> +ObjectProperty *
> +object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
> +                                    const uint8_t *v,
> +                                    ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_get_uint8_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_set_uint8_ptr;
> +    }
> +
> +    return object_class_property_add(klass, name, "uint8",
> +                                     getter, setter, NULL, (void *)v);
> +}
> +
> +ObjectProperty *
> +object_property_add_uint16_ptr(Object *obj, const char *name,
> +                               const uint16_t *v,
> +                               ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_get_uint16_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_set_uint16_ptr;
> +    }
> +
> +    return object_property_add(obj, name, "uint16",
> +                               getter, setter, NULL, (void *)v);
> +}
> +
> +ObjectProperty *
> +object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
> +                                     const uint16_t *v,
> +                                     ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_get_uint16_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_set_uint16_ptr;
> +    }
> +
> +    return object_class_property_add(klass, name, "uint16",
> +                                     getter, setter, NULL, (void *)v);
> +}
> +
> +ObjectProperty *
> +object_property_add_uint32_ptr(Object *obj, const char *name,
> +                               const uint32_t *v,
> +                               ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_get_uint32_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_set_uint32_ptr;
> +    }
> +
> +    return object_property_add(obj, name, "uint32",
> +                               getter, setter, NULL, (void *)v);
> +}
> +
> +ObjectProperty *
> +object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
> +                                     const uint32_t *v,
> +                                     ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_get_uint32_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_set_uint32_ptr;
> +    }
> +
> +    return object_class_property_add(klass, name, "uint32",
> +                                     getter, setter, NULL, (void *)v);
> +}
> +
> +ObjectProperty *
> +object_property_add_uint64_ptr(Object *obj, const char *name,
> +                               const uint64_t *v,
> +                               ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_get_uint64_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_set_uint64_ptr;
> +    }
> +
> +    return object_property_add(obj, name, "uint64",
> +                               getter, setter, NULL, (void *)v);
> +}
> +
> +ObjectProperty *
> +object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
> +                                     const uint64_t *v,
> +                                     ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_get_uint64_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_set_uint64_ptr;
> +    }
> +
> +    return object_class_property_add(klass, name, "uint64",
> +                                     getter, setter, NULL, (void *)v);
> +}
> diff --git a/qom/object.c b/qom/object.c
> index 0ac201de4c..fc738549dc 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -2673,246 +2673,6 @@ static char *object_get_type(Object *obj, Error **errp)
>       return g_strdup(object_get_typename(obj));
>   }
>   
> -static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *name,
> -                                   void *opaque, Error **errp)
> -{
> -    uint8_t value = *(uint8_t *)opaque;
> -    visit_type_uint8(v, name, &value, errp);
> -}
> -
> -static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name,
> -                                   void *opaque, Error **errp)
> -{
> -    uint8_t *field = opaque;
> -    uint8_t value;
> -
> -    if (!visit_type_uint8(v, name, &value, errp)) {
> -        return;
> -    }
> -
> -    *field = value;
> -}
> -
> -static void property_get_uint16_ptr(Object *obj, Visitor *v, const char *name,
> -                                    void *opaque, Error **errp)
> -{
> -    uint16_t value = *(uint16_t *)opaque;
> -    visit_type_uint16(v, name, &value, errp);
> -}
> -
> -static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name,
> -                                    void *opaque, Error **errp)
> -{
> -    uint16_t *field = opaque;
> -    uint16_t value;
> -
> -    if (!visit_type_uint16(v, name, &value, errp)) {
> -        return;
> -    }
> -
> -    *field = value;
> -}
> -
> -static void property_get_uint32_ptr(Object *obj, Visitor *v, const char *name,
> -                                    void *opaque, Error **errp)
> -{
> -    uint32_t value = *(uint32_t *)opaque;
> -    visit_type_uint32(v, name, &value, errp);
> -}
> -
> -static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name,
> -                                    void *opaque, Error **errp)
> -{
> -    uint32_t *field = opaque;
> -    uint32_t value;
> -
> -    if (!visit_type_uint32(v, name, &value, errp)) {
> -        return;
> -    }
> -
> -    *field = value;
> -}
> -
> -static void property_get_uint64_ptr(Object *obj, Visitor *v, const char *name,
> -                                    void *opaque, Error **errp)
> -{
> -    uint64_t value = *(uint64_t *)opaque;
> -    visit_type_uint64(v, name, &value, errp);
> -}
> -
> -static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
> -                                    void *opaque, Error **errp)
> -{
> -    uint64_t *field = opaque;
> -    uint64_t value;
> -
> -    if (!visit_type_uint64(v, name, &value, errp)) {
> -        return;
> -    }
> -
> -    *field = value;
> -}
> -
> -ObjectProperty *
> -object_property_add_uint8_ptr(Object *obj, const char *name,
> -                              const uint8_t *v,
> -                              ObjectPropertyFlags flags)
> -{
> -    ObjectPropertyAccessor *getter = NULL;
> -    ObjectPropertyAccessor *setter = NULL;
> -
> -    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> -        getter = property_get_uint8_ptr;
> -    }
> -
> -    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> -        setter = property_set_uint8_ptr;
> -    }
> -
> -    return object_property_add(obj, name, "uint8",
> -                               getter, setter, NULL, (void *)v);
> -}
> -
> -ObjectProperty *
> -object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
> -                                    const uint8_t *v,
> -                                    ObjectPropertyFlags flags)
> -{
> -    ObjectPropertyAccessor *getter = NULL;
> -    ObjectPropertyAccessor *setter = NULL;
> -
> -    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> -        getter = property_get_uint8_ptr;
> -    }
> -
> -    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> -        setter = property_set_uint8_ptr;
> -    }
> -
> -    return object_class_property_add(klass, name, "uint8",
> -                                     getter, setter, NULL, (void *)v);
> -}
> -
> -ObjectProperty *
> -object_property_add_uint16_ptr(Object *obj, const char *name,
> -                               const uint16_t *v,
> -                               ObjectPropertyFlags flags)
> -{
> -    ObjectPropertyAccessor *getter = NULL;
> -    ObjectPropertyAccessor *setter = NULL;
> -
> -    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> -        getter = property_get_uint16_ptr;
> -    }
> -
> -    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> -        setter = property_set_uint16_ptr;
> -    }
> -
> -    return object_property_add(obj, name, "uint16",
> -                               getter, setter, NULL, (void *)v);
> -}
> -
> -ObjectProperty *
> -object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
> -                                     const uint16_t *v,
> -                                     ObjectPropertyFlags flags)
> -{
> -    ObjectPropertyAccessor *getter = NULL;
> -    ObjectPropertyAccessor *setter = NULL;
> -
> -    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> -        getter = property_get_uint16_ptr;
> -    }
> -
> -    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> -        setter = property_set_uint16_ptr;
> -    }
> -
> -    return object_class_property_add(klass, name, "uint16",
> -                                     getter, setter, NULL, (void *)v);
> -}
> -
> -ObjectProperty *
> -object_property_add_uint32_ptr(Object *obj, const char *name,
> -                               const uint32_t *v,
> -                               ObjectPropertyFlags flags)
> -{
> -    ObjectPropertyAccessor *getter = NULL;
> -    ObjectPropertyAccessor *setter = NULL;
> -
> -    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> -        getter = property_get_uint32_ptr;
> -    }
> -
> -    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> -        setter = property_set_uint32_ptr;
> -    }
> -
> -    return object_property_add(obj, name, "uint32",
> -                               getter, setter, NULL, (void *)v);
> -}
> -
> -ObjectProperty *
> -object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
> -                                     const uint32_t *v,
> -                                     ObjectPropertyFlags flags)
> -{
> -    ObjectPropertyAccessor *getter = NULL;
> -    ObjectPropertyAccessor *setter = NULL;
> -
> -    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> -        getter = property_get_uint32_ptr;
> -    }
> -
> -    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> -        setter = property_set_uint32_ptr;
> -    }
> -
> -    return object_class_property_add(klass, name, "uint32",
> -                                     getter, setter, NULL, (void *)v);
> -}
> -
> -ObjectProperty *
> -object_property_add_uint64_ptr(Object *obj, const char *name,
> -                               const uint64_t *v,
> -                               ObjectPropertyFlags flags)
> -{
> -    ObjectPropertyAccessor *getter = NULL;
> -    ObjectPropertyAccessor *setter = NULL;
> -
> -    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> -        getter = property_get_uint64_ptr;
> -    }
> -
> -    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> -        setter = property_set_uint64_ptr;
> -    }
> -
> -    return object_property_add(obj, name, "uint64",
> -                               getter, setter, NULL, (void *)v);
> -}
> -
> -ObjectProperty *
> -object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
> -                                     const uint64_t *v,
> -                                     ObjectPropertyFlags flags)
> -{
> -    ObjectPropertyAccessor *getter = NULL;
> -    ObjectPropertyAccessor *setter = NULL;
> -
> -    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> -        getter = property_get_uint64_ptr;
> -    }
> -
> -    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> -        setter = property_set_uint64_ptr;
> -    }
> -
> -    return object_class_property_add(klass, name, "uint64",
> -                                     getter, setter, NULL, (void *)v);
> -}
> -
>   typedef struct {
>       Object *target_obj;
>       char *target_name;
> diff --git a/qom/meson.build b/qom/meson.build
> index bd6f4aadd7..2c746aaa9c 100644
> --- a/qom/meson.build
> +++ b/qom/meson.build
> @@ -3,6 +3,7 @@ qom_ss.add(files(
>     'container.c',
>     'object.c',
>     'object_interfaces.c',
> +  'object-property-ptr.c',
>     'qom-qobject.c',
>   ))
>   if have_system

Otherwise looks okay to me:

Reviewed-by: Mark Cave-Ayland <[email protected]>


ATB,

Mark.