* [PATCH 0/2] qdev: Typed array properties for better QOM introspection
@ 2026-11-04 8:38 Markus Armbruster
2026-11-04 8:38 ` [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration Markus Armbruster
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Markus Armbruster @ 2026-11-04 8:38 UTC (permalink / raw)
To: qemu-devel; +Cc: marcandre.lureau, pbonzini, berrange
In my "[PATCH v8 RESEND 00/56] qom/qdev: associate properties with
QAPI schema types", I noted under "Changes in v8":
* Drop typed array PropertyInfos
Why? They complicate matters, and I ran out of time.
This series brings them back. It's an updated version of PATCH 59+60
and a small part of PATCH 61 from Marc-André's v7.
With this applied on top of "[PATCH 0/4] qom/qdev: associate
properties with QAPI types fixups", only child and link properties
lack @qapi-type in my testing.
We could perhaps still include this in 11.2 as a bug fix, but I lean
towards queuing it up in my tree, with me taking care of the eventual
rebase.
Based-on: <20261104064552.959862-1-armbru@redhat.com>
Marc-André Lureau (2):
qdev: Convert array properties to QAPI-aware registration
qdev: Remove unused DEFINE_PROP_ARRAY parameter _arraytype
hw/core/qdev-prop-internal.h | 19 +++++++
hw/display/apple-gfx.h | 1 +
include/hw/block/block.h | 2 +-
include/hw/core/qdev-properties-system.h | 2 +
include/hw/core/qdev-properties.h | 37 +++++++-------
hw/core/qdev-properties-system.c | 6 +++
hw/core/qdev-properties.c | 64 ++++++++++++++----------
hw/input/stellaris_gamepad.c | 2 +-
hw/intc/arm_gicv3_common.c | 2 +-
hw/intc/arm_gicv5_common.c | 4 +-
hw/intc/rx_icu.c | 4 +-
hw/misc/arm_sysctl.c | 4 +-
hw/misc/mps2-scc.c | 2 +-
hw/net/rocker/rocker.c | 2 +-
hw/net/virtio-net.c | 2 +-
hw/nvram/xlnx-efuse.c | 2 +-
hw/nvram/xlnx-versal-efuse-ctrl.c | 2 +-
hw/riscv/riscv_hart.c | 6 +--
hw/virtio/virtio-iommu-pci.c | 2 +-
tests/unit/test-qdev.c | 2 +-
hw/display/apple-gfx-mmio.m | 2 +-
hw/display/apple-gfx-pci.m | 2 +-
hw/display/apple-gfx.m | 6 +++
23 files changed, 110 insertions(+), 67 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration
2026-11-04 8:38 [PATCH 0/2] qdev: Typed array properties for better QOM introspection Markus Armbruster
@ 2026-11-04 8:38 ` Markus Armbruster
2026-11-04 10:27 ` marcandre.lureau
2026-11-04 8:38 ` [PATCH 2/2] qdev: Remove unused DEFINE_PROP_ARRAY parameter _arraytype Markus Armbruster
2026-11-04 8:40 ` [PATCH 0/2] qdev: Typed array properties for better QOM introspection Markus Armbruster
2 siblings, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2026-11-04 8:38 UTC (permalink / raw)
To: qemu-devel; +Cc: marcandre.lureau, pbonzini, berrange
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Add element_info and element_size fields to PropertyInfo.
Add typed array PropertyInfo definitions. Each one knows its element
type at compile time through the new element_info and element_size
fields of PropertyInfo.
Update DEFINE_PROP_ARRAY() to use them instead of the generic
qdev_prop_array.
Use PropertyInfo fields element_info and element_size instead of
Property fields arrayinfo and arrayfieldsize. Remove arrayinfo and
arrayfieldsize.
Infrastructure changes:
- Make get_prop_array, set_prop_array, release_prop_array, and
default_prop_array non-static so they can be used by
DEFINE_PROP_ARRAY_INFO in other translation units
- Add DEFINE_PROP_ARRAY_INFO macro in qdev-prop-internal.h
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/core/qdev-prop-internal.h | 19 +++++++
hw/display/apple-gfx.h | 1 +
include/hw/core/qdev-properties-system.h | 2 +
include/hw/core/qdev-properties.h | 23 +++++----
hw/core/qdev-properties-system.c | 6 +++
hw/core/qdev-properties.c | 64 ++++++++++++++----------
hw/display/apple-gfx.m | 6 +++
7 files changed, 85 insertions(+), 36 deletions(-)
diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h
index d7b77844fe..4f89964c8f 100644
--- a/hw/core/qdev-prop-internal.h
+++ b/hw/core/qdev-prop-internal.h
@@ -25,4 +25,23 @@ 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);
+void get_prop_array(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp);
+void set_prop_array(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp);
+void release_prop_array(Object *obj, const char *name, void *opaque);
+void default_prop_array(ObjectProperty *op, const Property *prop);
+
+#define DEFINE_PROP_ARRAY_INFO(_prop_info, _c_type, _type_info) \
+ { \
+ .type = "list", \
+ .qapi_type = (_type_info), \
+ .element_info = &(_prop_info), \
+ .element_size = sizeof(_c_type), \
+ .get = get_prop_array, \
+ .set = set_prop_array, \
+ .release = release_prop_array, \
+ .set_default_value = default_prop_array, \
+ }
+
#endif
diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h
index 3197bd853d..652f158223 100644
--- a/hw/display/apple-gfx.h
+++ b/hw/display/apple-gfx.h
@@ -69,6 +69,7 @@ void *apple_gfx_host_ptr_for_gpa_range(uint64_t guest_physical,
MemoryRegion **mapping_in_region);
extern const PropertyInfo qdev_prop_apple_gfx_display_mode;
+extern const PropertyInfo qdev_prop_apple_gfx_display_mode_array;
#endif
diff --git a/include/hw/core/qdev-properties-system.h b/include/hw/core/qdev-properties-system.h
index 2cbea16d61..b20039ae55 100644
--- a/include/hw/core/qdev-properties-system.h
+++ b/include/hw/core/qdev-properties-system.h
@@ -23,6 +23,8 @@ extern const PropertyInfo qdev_prop_fdc_drive_type;
extern const PropertyInfo qdev_prop_drive;
extern const PropertyInfo qdev_prop_drive_iothread;
extern const PropertyInfo qdev_prop_netdev;
+extern const PropertyInfo qdev_prop_netdev_array;
+extern const PropertyInfo qdev_prop_reserved_region_array;
extern const PropertyInfo qdev_prop_pci_devfn;
extern const PropertyInfo qdev_prop_blocksize;
extern const PropertyInfo qdev_prop_pci_host_devaddr;
diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
index a57291a5a1..36a448be20 100644
--- a/include/hw/core/qdev-properties.h
+++ b/include/hw/core/qdev-properties.h
@@ -23,9 +23,7 @@ struct Property {
int64_t i;
uint64_t u;
} defval;
- const PropertyInfo *arrayinfo;
int arrayoffset;
- int arrayfieldsize;
uint8_t bitnr;
bool set_default;
};
@@ -34,6 +32,8 @@ struct PropertyInfo {
const char *type;
const char *description;
const QAPITypeInfo *qapi_type;
+ const struct PropertyInfo *element_info;
+ size_t element_size;
bool realized_set_allowed; /* allow setting property on realized device */
char *(*print)(Object *obj, const Property *prop);
void (*set_default_value)(ObjectProperty *op, const Property *prop);
@@ -73,8 +73,13 @@ extern const PropertyInfo qdev_prop_size;
extern const PropertyInfo qdev_prop_string;
extern const PropertyInfo qdev_prop_on_off_auto;
extern const PropertyInfo qdev_prop_size32;
-extern const PropertyInfo qdev_prop_array;
+extern const PropertyInfo qdev_prop_uint8_array;
+extern const PropertyInfo qdev_prop_uint16_array;
+extern const PropertyInfo qdev_prop_uint32_array;
+extern const PropertyInfo qdev_prop_uint64_array;
+extern const PropertyInfo qdev_prop_string_array;
extern const PropertyInfo qdev_prop_link;
+extern const PropertyInfo qdev_prop_link_array;
#define DEFINE_PROP(_name, _state, _field, _prop, _type, ...) { \
.name = (_name), \
@@ -141,7 +146,9 @@ extern const PropertyInfo qdev_prop_link;
* @_field: uint32_t field in @_state to hold the array length
* @_arrayfield: field in @_state (of type '@_arraytype *') which
* will point to the array
- * @_arrayprop: PropertyInfo defining what property the array elements have
+ * @_arrayprop: PropertyInfo for the array elements (e.g. qdev_prop_uint32);
+ * a corresponding array PropertyInfo named @_arrayprop##_array
+ * must exist
* @_arraytype: C type of the array elements
*
* Define device properties for a variable-length array _name. The array is
@@ -158,11 +165,9 @@ extern const PropertyInfo qdev_prop_link;
*/
#define DEFINE_PROP_ARRAY(_name, _state, _field, \
_arrayfield, _arrayprop, _arraytype) \
- DEFINE_PROP(_name, _state, _field, qdev_prop_array, uint32_t, \
+ DEFINE_PROP(_name, _state, _field, _arrayprop##_array, uint32_t, \
.set_default = true, \
.defval.u = 0, \
- .arrayinfo = &(_arrayprop), \
- .arrayfieldsize = sizeof(_arraytype), \
.arrayoffset = offsetof(_state, _arrayfield))
#define DEFINE_PROP_LINK(_name, _state, _field, _type, _ptr_type) \
@@ -187,11 +192,9 @@ extern const PropertyInfo qdev_prop_link;
*/
#define DEFINE_PROP_LINK_ARRAY(_name, _state, _field, _arrayfield, \
_linktype, _arraytype) \
- DEFINE_PROP(_name, _state, _field, qdev_prop_array, uint32_t, \
+ DEFINE_PROP(_name, _state, _field, qdev_prop_link_array, uint32_t, \
.set_default = true, \
.defval.u = 0, \
- .arrayinfo = &qdev_prop_link, \
- .arrayfieldsize = sizeof(_arraytype), \
.arrayoffset = offsetof(_state, _arrayfield), \
.link_type = _linktype)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 4d605c2056..923afa5cf3 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -489,6 +489,8 @@ const PropertyInfo qdev_prop_netdev = {
.set = set_netdev,
};
+const PropertyInfo qdev_prop_netdev_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_netdev, NICPeers, &strList_type_info);
/* --- audiodev --- */
static void get_audiodev(Object *obj, Visitor *v, const char* name,
@@ -840,6 +842,10 @@ const PropertyInfo qdev_prop_reserved_region = {
.set = set_reserved_region,
};
+const PropertyInfo qdev_prop_reserved_region_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_reserved_region, ReservedRegion,
+ &strList_type_info);
+
/* --- pci address --- */
/*
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index e2ea894595..7a7d4f9d79 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -681,7 +681,7 @@ static Property array_elem_prop(Object *obj, const Property *parent_prop,
const char *name, char *elem)
{
return (Property) {
- .info = parent_prop->arrayinfo,
+ .info = parent_prop->info->element_info,
.name = name,
/*
* This ugly piece of pointer arithmetic sets up the offset so
@@ -699,19 +699,21 @@ static Property array_elem_prop(Object *obj, const Property *parent_prop,
* underlying element's property release hook for each element and free the
* property array.
*/
-static void release_prop_array(Object *obj, const char *name, void *opaque)
+void release_prop_array(Object *obj, const char *name, void *opaque)
{
const Property *prop = opaque;
uint32_t *alenptr = object_field_prop_ptr(obj, prop);
void **arrayptr = (void *)obj + prop->arrayoffset;
char *elem = *arrayptr;
int i;
+ const PropertyInfo *elem_info = prop->info->element_info;
+ size_t elem_size = prop->info->element_size;
- if (prop->arrayinfo->release) {
+ if (elem_info->release) {
for (i = 0; i < *alenptr; i++) {
Property elem_prop = array_elem_prop(obj, prop, name, elem);
- prop->arrayinfo->release(obj, NULL, &elem_prop);
- elem += prop->arrayfieldsize;
+ elem_info->release(obj, NULL, &elem_prop);
+ elem += elem_size;
}
}
@@ -725,8 +727,8 @@ static void release_prop_array(Object *obj, const char *name, void *opaque)
* (a pointer to which is stored in the additional field described by
* prop->arrayoffset).
*/
-static void set_prop_array(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
+void set_prop_array(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
ERRP_GUARD();
const Property *prop = opaque;
@@ -734,6 +736,8 @@ static void set_prop_array(Object *obj, Visitor *v, const char *name,
void **arrayptr = (void *)obj + prop->arrayoffset;
ArrayElementList *list, *elem, *next;
const size_t size = sizeof(*list);
+ const PropertyInfo *elem_info = prop->info->element_info;
+ size_t elem_size = prop->info->element_size;
char *elemptr;
bool ok = true;
@@ -752,9 +756,9 @@ static void set_prop_array(Object *obj, Visitor *v, const char *name,
while (elem) {
Property elem_prop;
- elem->value = g_malloc0(prop->arrayfieldsize);
+ elem->value = g_malloc0(elem_size);
elem_prop = array_elem_prop(obj, prop, name, elem->value);
- prop->arrayinfo->set(obj, v, NULL, &elem_prop, errp);
+ elem_info->set(obj, v, NULL, &elem_prop, errp);
if (*errp) {
ok = false;
goto out_obj;
@@ -776,8 +780,8 @@ out_obj:
for (elem = list; elem; elem = next) {
Property elem_prop = array_elem_prop(obj, prop, name,
elem->value);
- if (prop->arrayinfo->release) {
- prop->arrayinfo->release(obj, NULL, &elem_prop);
+ if (elem_info->release) {
+ elem_info->release(obj, NULL, &elem_prop);
}
next = elem->next;
g_free(elem->value);
@@ -790,19 +794,19 @@ out_obj:
* Now that we know how big the array has to be, move the data over to a
* linear array and free the temporary list.
*/
- *arrayptr = g_malloc_n(*alenptr, prop->arrayfieldsize);
+ *arrayptr = g_malloc_n(*alenptr, elem_size);
elemptr = *arrayptr;
for (elem = list; elem; elem = next) {
- memcpy(elemptr, elem->value, prop->arrayfieldsize);
- elemptr += prop->arrayfieldsize;
+ memcpy(elemptr, elem->value, elem_size);
+ elemptr += elem_size;
next = elem->next;
g_free(elem->value);
g_free(elem);
}
}
-static void get_prop_array(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
+void get_prop_array(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
ERRP_GUARD();
const Property *prop = opaque;
@@ -812,6 +816,8 @@ static void get_prop_array(Object *obj, Visitor *v, const char *name,
ArrayElementList *list = NULL, *elem;
ArrayElementList **tail = &list;
const size_t size = sizeof(*list);
+ const PropertyInfo *elem_info = prop->info->element_info;
+ size_t elem_size = prop->info->element_size;
int i;
bool ok;
@@ -819,7 +825,7 @@ static void get_prop_array(Object *obj, Visitor *v, const char *name,
for (i = 0; i < *alenptr; i++) {
elem = g_new0(ArrayElementList, 1);
elem->value = elemptr;
- elemptr += prop->arrayfieldsize;
+ elemptr += elem_size;
*tail = elem;
tail = &elem->next;
@@ -832,7 +838,7 @@ static void get_prop_array(Object *obj, Visitor *v, const char *name,
elem = list;
while (elem) {
Property elem_prop = array_elem_prop(obj, prop, name, elem->value);
- prop->arrayinfo->get(obj, v, NULL, &elem_prop, errp);
+ elem_info->get(obj, v, NULL, &elem_prop, errp);
if (*errp) {
goto out_obj;
}
@@ -854,18 +860,24 @@ out_obj:
}
}
-static void default_prop_array(ObjectProperty *op, const Property *prop)
+void default_prop_array(ObjectProperty *op, const Property *prop)
{
object_property_set_default_list(op);
}
-const PropertyInfo qdev_prop_array = {
- .type = "list",
- .get = get_prop_array,
- .set = set_prop_array,
- .release = release_prop_array,
- .set_default_value = default_prop_array,
-};
+const PropertyInfo qdev_prop_uint8_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_uint8, uint8_t, &uint8List_type_info);
+const PropertyInfo qdev_prop_uint16_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_uint16, uint16_t, &uint16List_type_info);
+const PropertyInfo qdev_prop_uint32_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_uint32, uint32_t, &uint32List_type_info);
+const PropertyInfo qdev_prop_uint64_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_uint64, uint64_t, &uint64List_type_info);
+const PropertyInfo qdev_prop_string_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_string, char *, &strList_type_info);
+
+const PropertyInfo qdev_prop_link_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_link, void *, NULL);
/* --- public helpers --- */
diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m
index 4db80f0b10..f800f84aa2 100644
--- a/hw/display/apple-gfx.m
+++ b/hw/display/apple-gfx.m
@@ -16,6 +16,7 @@
#include "qemu/cutils.h"
#include "qemu/log.h"
#include "qapi/qapi-builtin-type-infos.h"
+#include "hw/core/qdev-prop-internal.h"
#include "qapi/visitor.h"
#include "qapi/error.h"
#include "qemu/aio-wait.h"
@@ -880,3 +881,8 @@ static void apple_gfx_set_display_mode(Object *obj, Visitor *v,
.get = apple_gfx_get_display_mode,
.set = apple_gfx_set_display_mode,
};
+
+const PropertyInfo qdev_prop_apple_gfx_display_mode_array =
+ DEFINE_PROP_ARRAY_INFO(qdev_prop_apple_gfx_display_mode,
+ AppleGFXDisplayMode,
+ &strList_type_info);
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] qdev: Remove unused DEFINE_PROP_ARRAY parameter _arraytype
2026-11-04 8:38 [PATCH 0/2] qdev: Typed array properties for better QOM introspection Markus Armbruster
2026-11-04 8:38 ` [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration Markus Armbruster
@ 2026-11-04 8:38 ` Markus Armbruster
2026-11-04 8:40 ` [PATCH 0/2] qdev: Typed array properties for better QOM introspection Markus Armbruster
2 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2026-11-04 8:38 UTC (permalink / raw)
To: qemu-devel; +Cc: marcandre.lureau, pbonzini, berrange
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
include/hw/block/block.h | 2 +-
include/hw/core/qdev-properties.h | 14 +++++---------
hw/input/stellaris_gamepad.c | 2 +-
hw/intc/arm_gicv3_common.c | 2 +-
hw/intc/arm_gicv5_common.c | 4 ++--
hw/intc/rx_icu.c | 4 ++--
hw/misc/arm_sysctl.c | 4 ++--
hw/misc/mps2-scc.c | 2 +-
hw/net/rocker/rocker.c | 2 +-
hw/net/virtio-net.c | 2 +-
hw/nvram/xlnx-efuse.c | 2 +-
hw/nvram/xlnx-versal-efuse-ctrl.c | 2 +-
hw/riscv/riscv_hart.c | 6 ++----
hw/virtio/virtio-iommu-pci.c | 2 +-
tests/unit/test-qdev.c | 2 +-
hw/display/apple-gfx-mmio.m | 2 +-
hw/display/apple-gfx-pci.m | 2 +-
17 files changed, 25 insertions(+), 31 deletions(-)
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
index c0a8b84df1..4a4c5f9292 100644
--- a/include/hw/block/block.h
+++ b/include/hw/block/block.h
@@ -83,7 +83,7 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
_conf.account_failed, ON_OFF_AUTO_AUTO), \
DEFINE_PROP_ARRAY("stats-intervals", _state, \
_conf.num_stats_intervals, _conf.stats_intervals, \
- qdev_prop_uint32, uint32_t)
+ qdev_prop_uint32)
#define DEFINE_BLOCK_PROPERTIES(_state, _conf) \
DEFINE_PROP_DRIVE("drive", _state, _conf.blk), \
diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
index 36a448be20..7187df0216 100644
--- a/include/hw/core/qdev-properties.h
+++ b/include/hw/core/qdev-properties.h
@@ -144,17 +144,15 @@ extern const PropertyInfo qdev_prop_link_array;
* @_name: name of the array
* @_state: name of the device state structure type
* @_field: uint32_t field in @_state to hold the array length
- * @_arrayfield: field in @_state (of type '@_arraytype *') which
- * will point to the array
+ * @_arrayfield: field in @_state which will point to the array
* @_arrayprop: PropertyInfo for the array elements (e.g. qdev_prop_uint32);
* a corresponding array PropertyInfo named @_arrayprop##_array
* must exist
- * @_arraytype: C type of the array elements
*
* Define device properties for a variable-length array _name. The array is
* represented as a list in the visitor interface.
*
- * @_arraytype is required to be movable with memcpy().
+ * The element type must be movable with memcpy().
*
* When the array property is set, the @_field member of the device
* struct is set to the array length, and @_arrayfield is set to point
@@ -164,7 +162,7 @@ extern const PropertyInfo qdev_prop_link_array;
* @_arrayfield memory.
*/
#define DEFINE_PROP_ARRAY(_name, _state, _field, \
- _arrayfield, _arrayprop, _arraytype) \
+ _arrayfield, _arrayprop) \
DEFINE_PROP(_name, _state, _field, _arrayprop##_array, uint32_t, \
.set_default = true, \
.defval.u = 0, \
@@ -179,10 +177,8 @@ extern const PropertyInfo qdev_prop_link_array;
* @_name: name of the array
* @_state: name of the device state structure type
* @_field: uint32_t field in @_state to hold the array length
- * @_arrayfield: field in @_state (of type '@_arraytype *') which
- * will point to the array
+ * @_arrayfield: field in @_state which will point to the array
* @_linktype: QOM type name of the link type
- * @_arraytype: C type of the array elements
*
* Define device properties for a variable-length array _name of links
* (i.e. this is the array version of DEFINE_PROP_LINK).
@@ -191,7 +187,7 @@ extern const PropertyInfo qdev_prop_link_array;
* where each string is the QOM path of the object to be linked.
*/
#define DEFINE_PROP_LINK_ARRAY(_name, _state, _field, _arrayfield, \
- _linktype, _arraytype) \
+ _linktype) \
DEFINE_PROP(_name, _state, _field, qdev_prop_link_array, uint32_t, \
.set_default = true, \
.defval.u = 0, \
diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c
index 376d91abad..20613f6499 100644
--- a/hw/input/stellaris_gamepad.c
+++ b/hw/input/stellaris_gamepad.c
@@ -80,7 +80,7 @@ static void stellaris_gamepad_reset_enter(Object *obj, ResetType type)
static const Property stellaris_gamepad_properties[] = {
DEFINE_PROP_ARRAY("keycodes", StellarisGamepad, num_buttons,
- keycodes, qdev_prop_uint32, uint32_t),
+ keycodes, qdev_prop_uint32),
};
static void stellaris_gamepad_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
index f7ba74e6d5..1298b6b735 100644
--- a/hw/intc/arm_gicv3_common.c
+++ b/hw/intc/arm_gicv3_common.c
@@ -615,7 +615,7 @@ static const Property arm_gicv3_common_properties[] = {
*/
DEFINE_PROP_BOOL("force-8-bit-prio", GICv3State, force_8bit_prio, 0),
DEFINE_PROP_ARRAY("redist-region-count", GICv3State, nb_redist_regions,
- redist_region_count, qdev_prop_uint32, uint32_t),
+ redist_region_count, qdev_prop_uint32),
DEFINE_PROP_LINK("sysmem", GICv3State, dma, TYPE_MEMORY_REGION,
MemoryRegion *),
DEFINE_PROP_UINT32("first-cpu-index", GICv3State, first_cpu_idx, 0),
diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c
index 2920b11cc3..40c1956a47 100644
--- a/hw/intc/arm_gicv5_common.c
+++ b/hw/intc/arm_gicv5_common.c
@@ -191,9 +191,9 @@ static void gicv5_common_realize(DeviceState *dev, Error **errp)
static const Property arm_gicv5_common_properties[] = {
DEFINE_PROP_LINK_ARRAY("cpus", GICv5Common, num_cpus,
- cpus, TYPE_ARM_CPU, ARMCPU *),
+ cpus, TYPE_ARM_CPU),
DEFINE_PROP_ARRAY("cpu-iaffids", GICv5Common, num_cpu_iaffids,
- cpu_iaffids, qdev_prop_uint32, uint32_t),
+ cpu_iaffids, qdev_prop_uint32),
DEFINE_PROP_UINT32("irsid", GICv5Common, irsid, 0),
DEFINE_PROP_UINT32("spi-range", GICv5Common, spi_range, 0),
DEFINE_PROP_UINT32("spi-base", GICv5Common, spi_base, 0),
diff --git a/hw/intc/rx_icu.c b/hw/intc/rx_icu.c
index 992b069ae2..125a6dcb68 100644
--- a/hw/intc/rx_icu.c
+++ b/hw/intc/rx_icu.c
@@ -356,9 +356,9 @@ static const VMStateDescription vmstate_rxicu = {
static const Property rxicu_properties[] = {
DEFINE_PROP_ARRAY("ipr-map", RXICUState, nr_irqs, map,
- qdev_prop_uint8, uint8_t),
+ qdev_prop_uint8),
DEFINE_PROP_ARRAY("trigger-level", RXICUState, nr_sense, init_sense,
- qdev_prop_uint8, uint8_t),
+ qdev_prop_uint8),
};
static void rxicu_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c
index ebc95b9bb5..1df85593a5 100644
--- a/hw/misc/arm_sysctl.c
+++ b/hw/misc/arm_sysctl.c
@@ -626,10 +626,10 @@ static const Property arm_sysctl_properties[] = {
DEFINE_PROP_UINT32("proc_id", arm_sysctl_state, proc_id, 0),
/* Daughterboard power supply voltages (as reported via SYS_CFG) */
DEFINE_PROP_ARRAY("db-voltage", arm_sysctl_state, db_num_vsensors,
- db_voltage, qdev_prop_uint32, uint32_t),
+ db_voltage, qdev_prop_uint32),
/* Daughterboard clock reset values (as reported via SYS_CFG) */
DEFINE_PROP_ARRAY("db-clock", arm_sysctl_state, db_num_clocks,
- db_clock_reset, qdev_prop_uint32, uint32_t),
+ db_clock_reset, qdev_prop_uint32),
};
static void arm_sysctl_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
index 554b504c72..32f9e166fe 100644
--- a/hw/misc/mps2-scc.c
+++ b/hw/misc/mps2-scc.c
@@ -464,7 +464,7 @@ static const Property mps2_scc_properties[] = {
* motherboard configuration controller to suit the FPGA image.
*/
DEFINE_PROP_ARRAY("oscclk", MPS2SCC, num_oscclk, oscclk_reset,
- qdev_prop_uint32, uint32_t),
+ qdev_prop_uint32),
};
static void mps2_scc_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 910dce901b..afbc32e99d 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -1466,7 +1466,7 @@ static const Property rocker_properties[] = {
DEFINE_PROP_UINT64("switch_id", Rocker,
switch_id, 0),
DEFINE_PROP_ARRAY("ports", Rocker, fp_ports,
- fp_ports_peers, qdev_prop_netdev, NICPeers),
+ fp_ports_peers, qdev_prop_netdev),
};
static const VMStateDescription rocker_vmsd = {
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 54e42cfec9..0bdd5a005d 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -4380,7 +4380,7 @@ static const Property virtio_net_properties[] = {
DEFINE_PROP_BIT64("hash", VirtIONet, host_features,
VIRTIO_NET_F_HASH_REPORT, false),
DEFINE_PROP_ARRAY("ebpf-rss-fds", VirtIONet, nr_ebpf_rss_fds,
- ebpf_rss_fds, qdev_prop_string, char*),
+ ebpf_rss_fds, qdev_prop_string),
DEFINE_PROP_BIT64("guest_rsc_ext", VirtIONet, host_features,
VIRTIO_NET_F_RSC_EXT, false),
DEFINE_PROP_UINT32("rsc_interval", VirtIONet, rsc_timeout,
diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c
index 7d2030f7aa..c75704662a 100644
--- a/hw/nvram/xlnx-efuse.c
+++ b/hw/nvram/xlnx-efuse.c
@@ -267,7 +267,7 @@ static const Property efuse_properties[] = {
DEFINE_PROP_UINT32("efuse-size", XlnxEFuse, efuse_size, 64 * 32),
DEFINE_PROP_BOOL("init-factory-tbits", XlnxEFuse, init_tbits, true),
DEFINE_PROP_ARRAY("read-only", XlnxEFuse, ro_bits_cnt, ro_bits,
- qdev_prop_uint32, uint32_t),
+ qdev_prop_uint32),
};
static void efuse_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c
index f5d5587cb6..101320b82f 100644
--- a/hw/nvram/xlnx-versal-efuse-ctrl.c
+++ b/hw/nvram/xlnx-versal-efuse-ctrl.c
@@ -740,7 +740,7 @@ static const Property efuse_ctrl_props[] = {
TYPE_XLNX_EFUSE, XlnxEFuse *),
DEFINE_PROP_ARRAY("pg0-lock",
XlnxVersalEFuseCtrl, extra_pg0_lock_n16,
- extra_pg0_lock_spec, qdev_prop_uint16, uint16_t),
+ extra_pg0_lock_spec, qdev_prop_uint16),
};
static void efuse_ctrl_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c
index 32fd39737f..132cf87370 100644
--- a/hw/riscv/riscv_hart.c
+++ b/hw/riscv/riscv_hart.c
@@ -48,11 +48,9 @@ static const Property riscv_harts_props[] = {
* defined by "rnmi-exception-vector".
*/
DEFINE_PROP_ARRAY("rnmi-interrupt-vector", RISCVHartArrayState,
- num_rnmi_irqvec, rnmi_irqvec, qdev_prop_uint64,
- uint64_t),
+ num_rnmi_irqvec, rnmi_irqvec, qdev_prop_uint64),
DEFINE_PROP_ARRAY("rnmi-exception-vector", RISCVHartArrayState,
- num_rnmi_excpvec, rnmi_excpvec, qdev_prop_uint64,
- uint64_t),
+ num_rnmi_excpvec, rnmi_excpvec, qdev_prop_uint64),
DEFINE_PROP_LINK("memory", RISCVHartArrayState, memory,
TYPE_MEMORY_REGION, MemoryRegion *),
};
diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c
index 7b5ffddc1e..1f3a07c5d1 100644
--- a/hw/virtio/virtio-iommu-pci.c
+++ b/hw/virtio/virtio-iommu-pci.c
@@ -38,7 +38,7 @@ static const Property virtio_iommu_pci_properties[] = {
DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0),
DEFINE_PROP_ARRAY("reserved-regions", VirtIOIOMMUPCI,
vdev.nr_prop_resv_regions, vdev.prop_resv_regions,
- qdev_prop_reserved_region, ReservedRegion),
+ qdev_prop_reserved_region),
};
static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
diff --git a/tests/unit/test-qdev.c b/tests/unit/test-qdev.c
index 77c3eee717..8cd004b1ef 100644
--- a/tests/unit/test-qdev.c
+++ b/tests/unit/test-qdev.c
@@ -23,7 +23,7 @@ static const Property my_dev_props[] = {
DEFINE_PROP_UINT32("u32", MyDev, prop_u32, 100),
DEFINE_PROP_STRING("string", MyDev, prop_string),
DEFINE_PROP_ARRAY("array-u32", MyDev, prop_array_u32_nb, prop_array_u32,
- qdev_prop_uint32, uint32_t),
+ qdev_prop_uint32),
};
static void my_dev_class_init(ObjectClass *oc, const void *data)
diff --git a/hw/display/apple-gfx-mmio.m b/hw/display/apple-gfx-mmio.m
index 58beaadd1f..dcd04617eb 100644
--- a/hw/display/apple-gfx-mmio.m
+++ b/hw/display/apple-gfx-mmio.m
@@ -258,7 +258,7 @@ static void apple_gfx_mmio_reset(Object *obj, ResetType type)
static const Property apple_gfx_mmio_properties[] = {
DEFINE_PROP_ARRAY("display-modes", AppleGFXMMIOState,
common.num_display_modes, common.display_modes,
- qdev_prop_apple_gfx_display_mode, AppleGFXDisplayMode),
+ qdev_prop_apple_gfx_display_mode),
};
static void apple_gfx_mmio_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/display/apple-gfx-pci.m b/hw/display/apple-gfx-pci.m
index b0694f4cb8..74f79c8b15 100644
--- a/hw/display/apple-gfx-pci.m
+++ b/hw/display/apple-gfx-pci.m
@@ -118,7 +118,7 @@ static void apple_gfx_pci_reset(Object *obj, ResetType type)
static const Property apple_gfx_pci_properties[] = {
DEFINE_PROP_ARRAY("display-modes", AppleGFXPCIState,
common.num_display_modes, common.display_modes,
- qdev_prop_apple_gfx_display_mode, AppleGFXDisplayMode),
+ qdev_prop_apple_gfx_display_mode),
};
static void apple_gfx_pci_class_init(ObjectClass *klass, const void *data)
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] qdev: Typed array properties for better QOM introspection
2026-11-04 8:38 [PATCH 0/2] qdev: Typed array properties for better QOM introspection Markus Armbruster
2026-11-04 8:38 ` [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration Markus Armbruster
2026-11-04 8:38 ` [PATCH 2/2] qdev: Remove unused DEFINE_PROP_ARRAY parameter _arraytype Markus Armbruster
@ 2026-11-04 8:40 ` Markus Armbruster
2 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2026-11-04 8:40 UTC (permalink / raw)
To: qemu-devel; +Cc: marcandre.lureau, pbonzini, berrange
Markus Armbruster <armbru@redhat.com> writes:
> In my "[PATCH v8 RESEND 00/56] qom/qdev: associate properties with
> QAPI schema types", I noted under "Changes in v8":
>
> * Drop typed array PropertyInfos
>
> Why? They complicate matters, and I ran out of time.
>
> This series brings them back. It's an updated version of PATCH 59+60
> and a small part of PATCH 61 from Marc-André's v7.
Forgot to mention: I managed to do without the QAPI generator changes.
[...]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration
2026-11-04 8:38 ` [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration Markus Armbruster
@ 2026-11-04 10:27 ` marcandre.lureau
2026-11-05 6:47 ` Markus Armbruster
0 siblings, 1 reply; 7+ messages in thread
From: marcandre.lureau @ 2026-11-04 10:27 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, marcandre.lureau, pbonzini, berrange
> Add element_info and element_size fields to PropertyInfo.
>
> Add typed array PropertyInfo definitions. Each one knows its element
> type at compile time through the new element_info and element_size
> fields of PropertyInfo.
>
> Update DEFINE_PROP_ARRAY() to use them instead of the generic
> qdev_prop_array.
>
> Use PropertyInfo fields element_info and element_size instead of
> Property fields arrayinfo and arrayfieldsize. Remove arrayinfo and
> arrayfieldsize.
>
> Infrastructure changes:
> - Make get_prop_array, set_prop_array, release_prop_array, and
> default_prop_array non-static so they can be used by
> DEFINE_PROP_ARRAY_INFO in other translation units
> - Add DEFINE_PROP_ARRAY_INFO macro in qdev-prop-internal.h
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Message-ID: <20261104083816.1120306-2-armbru@redhat.com>
> ---
> hw/core/qdev-prop-internal.h | 19 +++++++
> hw/display/apple-gfx.h | 1 +
> include/hw/core/qdev-properties-system.h | 2 +
> include/hw/core/qdev-properties.h | 23 +++++----
> hw/core/qdev-properties-system.c | 6 +++
> hw/core/qdev-properties.c | 64 ++++++++++++++----------
> hw/display/apple-gfx.m | 6 +++
> 7 files changed, 85 insertions(+), 36 deletions(-)
>
> diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h
> index d7b77844fe0b..4f89964c8fc8 100644
> --- a/hw/core/qdev-prop-internal.h
> +++ b/hw/core/qdev-prop-internal.h
> @@ -25,4 +25,23 @@ 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);
>
> +void get_prop_array(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp);
> +void set_prop_array(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp);
> +void release_prop_array(Object *obj, const char *name, void *opaque);
> +void default_prop_array(ObjectProperty *op, const Property *prop);
> +
> +#define DEFINE_PROP_ARRAY_INFO(_prop_info, _c_type, _type_info) \
> + { \
> + .type = "list", \
> + .qapi_type = (_type_info), \
> + .element_info = &(_prop_info), \
> + .element_size = sizeof(_c_type), \
> + .get = get_prop_array, \
> + .set = set_prop_array, \
> + .release = release_prop_array, \
> + .set_default_value = default_prop_array, \
> + }
> +
> #endif
> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
> index 4d605c205615..923afa5cf354 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -489,6 +489,8 @@ const PropertyInfo qdev_prop_netdev = {
> .set = set_netdev,
> };
>
> +const PropertyInfo qdev_prop_netdev_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_netdev, NICPeers, &strList_type_info);
>
> /* --- audiodev --- */
> static void get_audiodev(Object *obj, Visitor *v, const char* name,
> @@ -840,6 +842,10 @@ const PropertyInfo qdev_prop_reserved_region = {
> .set = set_reserved_region,
> };
>
> +const PropertyInfo qdev_prop_reserved_region_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_reserved_region, ReservedRegion,
> + &strList_type_info);
> +
> /* --- pci address --- */
>
> /*
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index e2ea8945956c..7a7d4f9d7910 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -681,7 +681,7 @@ static Property array_elem_prop(Object *obj, const Property *parent_prop,
> const char *name, char *elem)
> {
> return (Property) {
> - .info = parent_prop->arrayinfo,
> + .info = parent_prop->info->element_info,
> .name = name,
> /*
> * This ugly piece of pointer arithmetic sets up the offset so
> @@ -699,19 +699,21 @@ static Property array_elem_prop(Object *obj, const Property *parent_prop,
> * underlying element's property release hook for each element and free the
> * property array.
> */
> -static void release_prop_array(Object *obj, const char *name, void *opaque)
> +void release_prop_array(Object *obj, const char *name, void *opaque)
> {
> const Property *prop = opaque;
> uint32_t *alenptr = object_field_prop_ptr(obj, prop);
> void **arrayptr = (void *)obj + prop->arrayoffset;
> char *elem = *arrayptr;
> int i;
> + const PropertyInfo *elem_info = prop->info->element_info;
> + size_t elem_size = prop->info->element_size;
>
> - if (prop->arrayinfo->release) {
> + if (elem_info->release) {
> for (i = 0; i < *alenptr; i++) {
> Property elem_prop = array_elem_prop(obj, prop, name, elem);
> - prop->arrayinfo->release(obj, NULL, &elem_prop);
> - elem += prop->arrayfieldsize;
> + elem_info->release(obj, NULL, &elem_prop);
> + elem += elem_size;
> }
> }
>
> @@ -725,8 +727,8 @@ static void release_prop_array(Object *obj, const char *name, void *opaque)
> * (a pointer to which is stored in the additional field described by
> * prop->arrayoffset).
> */
> -static void set_prop_array(Object *obj, Visitor *v, const char *name,
> - void *opaque, Error **errp)
> +void set_prop_array(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> {
> ERRP_GUARD();
> const Property *prop = opaque;
> @@ -734,6 +736,8 @@ static void set_prop_array(Object *obj, Visitor *v, const char *name,
> void **arrayptr = (void *)obj + prop->arrayoffset;
> ArrayElementList *list, *elem, *next;
> const size_t size = sizeof(*list);
> + const PropertyInfo *elem_info = prop->info->element_info;
> + size_t elem_size = prop->info->element_size;
> char *elemptr;
> bool ok = true;
>
> @@ -752,9 +756,9 @@ static void set_prop_array(Object *obj, Visitor *v, const char *name,
> while (elem) {
> Property elem_prop;
>
> - elem->value = g_malloc0(prop->arrayfieldsize);
> + elem->value = g_malloc0(elem_size);
> elem_prop = array_elem_prop(obj, prop, name, elem->value);
> - prop->arrayinfo->set(obj, v, NULL, &elem_prop, errp);
> + elem_info->set(obj, v, NULL, &elem_prop, errp);
> if (*errp) {
> ok = false;
> goto out_obj;
> @@ -776,8 +780,8 @@ out_obj:
> for (elem = list; elem; elem = next) {
> Property elem_prop = array_elem_prop(obj, prop, name,
> elem->value);
> - if (prop->arrayinfo->release) {
> - prop->arrayinfo->release(obj, NULL, &elem_prop);
> + if (elem_info->release) {
> + elem_info->release(obj, NULL, &elem_prop);
> }
> next = elem->next;
> g_free(elem->value);
> @@ -790,19 +794,19 @@ out_obj:
> * Now that we know how big the array has to be, move the data over to a
> * linear array and free the temporary list.
> */
> - *arrayptr = g_malloc_n(*alenptr, prop->arrayfieldsize);
> + *arrayptr = g_malloc_n(*alenptr, elem_size);
> elemptr = *arrayptr;
> for (elem = list; elem; elem = next) {
> - memcpy(elemptr, elem->value, prop->arrayfieldsize);
> - elemptr += prop->arrayfieldsize;
> + memcpy(elemptr, elem->value, elem_size);
> + elemptr += elem_size;
> next = elem->next;
> g_free(elem->value);
> g_free(elem);
> }
> }
>
> -static void get_prop_array(Object *obj, Visitor *v, const char *name,
> - void *opaque, Error **errp)
> +void get_prop_array(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> {
> ERRP_GUARD();
> const Property *prop = opaque;
> @@ -812,6 +816,8 @@ static void get_prop_array(Object *obj, Visitor *v, const char *name,
> ArrayElementList *list = NULL, *elem;
> ArrayElementList **tail = &list;
> const size_t size = sizeof(*list);
> + const PropertyInfo *elem_info = prop->info->element_info;
> + size_t elem_size = prop->info->element_size;
> int i;
> bool ok;
>
> @@ -819,7 +825,7 @@ static void get_prop_array(Object *obj, Visitor *v, const char *name,
> for (i = 0; i < *alenptr; i++) {
> elem = g_new0(ArrayElementList, 1);
> elem->value = elemptr;
> - elemptr += prop->arrayfieldsize;
> + elemptr += elem_size;
>
> *tail = elem;
> tail = &elem->next;
> @@ -832,7 +838,7 @@ static void get_prop_array(Object *obj, Visitor *v, const char *name,
> elem = list;
> while (elem) {
> Property elem_prop = array_elem_prop(obj, prop, name, elem->value);
> - prop->arrayinfo->get(obj, v, NULL, &elem_prop, errp);
> + elem_info->get(obj, v, NULL, &elem_prop, errp);
> if (*errp) {
> goto out_obj;
> }
> @@ -854,18 +860,24 @@ out_obj:
> }
> }
>
> -static void default_prop_array(ObjectProperty *op, const Property *prop)
> +void default_prop_array(ObjectProperty *op, const Property *prop)
> {
> object_property_set_default_list(op);
> }
>
> -const PropertyInfo qdev_prop_array = {
> - .type = "list",
> - .get = get_prop_array,
> - .set = set_prop_array,
> - .release = release_prop_array,
> - .set_default_value = default_prop_array,
> -};
> +const PropertyInfo qdev_prop_uint8_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint8, uint8_t, &uint8List_type_info);
> +const PropertyInfo qdev_prop_uint16_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint16, uint16_t, &uint16List_type_info);
> +const PropertyInfo qdev_prop_uint32_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint32, uint32_t, &uint32List_type_info);
> +const PropertyInfo qdev_prop_uint64_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint64, uint64_t, &uint64List_type_info);
> +const PropertyInfo qdev_prop_string_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_string, char *, &strList_type_info);
> +
> +const PropertyInfo qdev_prop_link_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_link, void *, NULL);
It could use &strList_type_info, since qdev_prop_link uses
&str_type_info and serialize as object-path strings.
>
> /* --- public helpers --- */
>
> diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h
> index 3197bd853dab..652f158223c0 100644
> --- a/hw/display/apple-gfx.h
> +++ b/hw/display/apple-gfx.h
> @@ -69,6 +69,7 @@ void *apple_gfx_host_ptr_for_gpa_range(uint64_t guest_physical,
> MemoryRegion **mapping_in_region);
>
> extern const PropertyInfo qdev_prop_apple_gfx_display_mode;
> +extern const PropertyInfo qdev_prop_apple_gfx_display_mode_array;
>
> #endif
>
> diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m
> index 4db80f0b107e..f800f84aa2b5 100644
> --- a/hw/display/apple-gfx.m
> +++ b/hw/display/apple-gfx.m
> @@ -16,6 +16,7 @@
> #include "qemu/cutils.h"
> #include "qemu/log.h"
> #include "qapi/qapi-builtin-type-infos.h"
> +#include "hw/core/qdev-prop-internal.h"
> #include "qapi/visitor.h"
> #include "qapi/error.h"
> #include "qemu/aio-wait.h"
> @@ -880,3 +881,8 @@ static void apple_gfx_set_display_mode(Object *obj, Visitor *v,
> .get = apple_gfx_get_display_mode,
> .set = apple_gfx_set_display_mode,
> };
> +
> +const PropertyInfo qdev_prop_apple_gfx_display_mode_array =
> + DEFINE_PROP_ARRAY_INFO(qdev_prop_apple_gfx_display_mode,
> + AppleGFXDisplayMode,
> + &strList_type_info);
indented with tabs
--
Marc-André Lureau <marcandre.lureau@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration
2026-11-04 10:27 ` marcandre.lureau
@ 2026-11-05 6:47 ` Markus Armbruster
2026-11-05 7:35 ` Markus Armbruster
0 siblings, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2026-11-05 6:47 UTC (permalink / raw)
To: marcandre.lureau; +Cc: Markus Armbruster, qemu-devel, pbonzini, berrange
marcandre.lureau@redhat.com writes:
>> Add element_info and element_size fields to PropertyInfo.
>>
>> Add typed array PropertyInfo definitions. Each one knows its element
>> type at compile time through the new element_info and element_size
>> fields of PropertyInfo.
>>
>> Update DEFINE_PROP_ARRAY() to use them instead of the generic
>> qdev_prop_array.
>>
>> Use PropertyInfo fields element_info and element_size instead of
>> Property fields arrayinfo and arrayfieldsize. Remove arrayinfo and
>> arrayfieldsize.
>>
>> Infrastructure changes:
>> - Make get_prop_array, set_prop_array, release_prop_array, and
>> default_prop_array non-static so they can be used by
>> DEFINE_PROP_ARRAY_INFO in other translation units
>> - Add DEFINE_PROP_ARRAY_INFO macro in qdev-prop-internal.h
>>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> Message-ID: <20261104083816.1120306-2-armbru@redhat.com>
[...]
>> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>> index e2ea8945956c..7a7d4f9d7910 100644
>> --- a/hw/core/qdev-properties.c
>> +++ b/hw/core/qdev-properties.c
[...]
>> @@ -854,18 +860,24 @@ out_obj:
>> }
>> }
>>
>> -static void default_prop_array(ObjectProperty *op, const Property *prop)
>> +void default_prop_array(ObjectProperty *op, const Property *prop)
>> {
>> object_property_set_default_list(op);
>> }
>>
>> -const PropertyInfo qdev_prop_array = {
>> - .type = "list",
>> - .get = get_prop_array,
>> - .set = set_prop_array,
>> - .release = release_prop_array,
>> - .set_default_value = default_prop_array,
>> -};
>> +const PropertyInfo qdev_prop_uint8_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint8, uint8_t, &uint8List_type_info);
>> +const PropertyInfo qdev_prop_uint16_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint16, uint16_t, &uint16List_type_info);
>> +const PropertyInfo qdev_prop_uint32_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint32, uint32_t, &uint32List_type_info);
>> +const PropertyInfo qdev_prop_uint64_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint64, uint64_t, &uint64List_type_info);
>> +const PropertyInfo qdev_prop_string_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_string, char *, &strList_type_info);
>> +
>> +const PropertyInfo qdev_prop_link_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_link, void *, NULL);
>
> It could use &strList_type_info, since qdev_prop_link uses
> &str_type_info and serialize as object-path strings.
Point.
>> /* --- public helpers --- */
>>
>> diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h
>> index 3197bd853dab..652f158223c0 100644
>> --- a/hw/display/apple-gfx.h
>> +++ b/hw/display/apple-gfx.h
>> @@ -69,6 +69,7 @@ void *apple_gfx_host_ptr_for_gpa_range(uint64_t guest_physical,
>> MemoryRegion **mapping_in_region);
>>
>> extern const PropertyInfo qdev_prop_apple_gfx_display_mode;
>> +extern const PropertyInfo qdev_prop_apple_gfx_display_mode_array;
>>
>> #endif
>>
>> diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m
>> index 4db80f0b107e..f800f84aa2b5 100644
>> --- a/hw/display/apple-gfx.m
>> +++ b/hw/display/apple-gfx.m
>> @@ -16,6 +16,7 @@
>> #include "qemu/cutils.h"
>> #include "qemu/log.h"
>> #include "qapi/qapi-builtin-type-infos.h"
>> +#include "hw/core/qdev-prop-internal.h"
>> #include "qapi/visitor.h"
>> #include "qapi/error.h"
>> #include "qemu/aio-wait.h"
>> @@ -880,3 +881,8 @@ static void apple_gfx_set_display_mode(Object *obj, Visitor *v,
>> .get = apple_gfx_get_display_mode,
>> .set = apple_gfx_set_display_mode,
>> };
>> +
>> +const PropertyInfo qdev_prop_apple_gfx_display_mode_array =
>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_apple_gfx_display_mode,
>> + AppleGFXDisplayMode,
>> + &strList_type_info);
>
> indented with tabs
Oops.
Thank you!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration
2026-11-05 6:47 ` Markus Armbruster
@ 2026-11-05 7:35 ` Markus Armbruster
0 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2026-11-05 7:35 UTC (permalink / raw)
To: marcandre.lureau; +Cc: qemu-devel, pbonzini, berrange
Markus Armbruster <armbru@redhat.com> writes:
> marcandre.lureau@redhat.com writes:
>
>>> Add element_info and element_size fields to PropertyInfo.
>>>
>>> Add typed array PropertyInfo definitions. Each one knows its element
>>> type at compile time through the new element_info and element_size
>>> fields of PropertyInfo.
>>>
>>> Update DEFINE_PROP_ARRAY() to use them instead of the generic
>>> qdev_prop_array.
>>>
>>> Use PropertyInfo fields element_info and element_size instead of
>>> Property fields arrayinfo and arrayfieldsize. Remove arrayinfo and
>>> arrayfieldsize.
>>>
>>> Infrastructure changes:
>>> - Make get_prop_array, set_prop_array, release_prop_array, and
>>> default_prop_array non-static so they can be used by
>>> DEFINE_PROP_ARRAY_INFO in other translation units
>>> - Add DEFINE_PROP_ARRAY_INFO macro in qdev-prop-internal.h
>>>
>>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>> Message-ID: <20261104083816.1120306-2-armbru@redhat.com>
>
> [...]
>
>>> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>>> index e2ea8945956c..7a7d4f9d7910 100644
>>> --- a/hw/core/qdev-properties.c
>>> +++ b/hw/core/qdev-properties.c
>
> [...]
>
>>> @@ -854,18 +860,24 @@ out_obj:
>>> }
>>> }
>>>
>>> -static void default_prop_array(ObjectProperty *op, const Property *prop)
>>> +void default_prop_array(ObjectProperty *op, const Property *prop)
>>> {
>>> object_property_set_default_list(op);
>>> }
>>>
>>> -const PropertyInfo qdev_prop_array = {
>>> - .type = "list",
>>> - .get = get_prop_array,
>>> - .set = set_prop_array,
>>> - .release = release_prop_array,
>>> - .set_default_value = default_prop_array,
>>> -};
>>> +const PropertyInfo qdev_prop_uint8_array =
>>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint8, uint8_t, &uint8List_type_info);
>>> +const PropertyInfo qdev_prop_uint16_array =
>>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint16, uint16_t, &uint16List_type_info);
>>> +const PropertyInfo qdev_prop_uint32_array =
>>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint32, uint32_t, &uint32List_type_info);
>>> +const PropertyInfo qdev_prop_uint64_array =
>>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_uint64, uint64_t, &uint64List_type_info);
>>> +const PropertyInfo qdev_prop_string_array =
>>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_string, char *, &strList_type_info);
>>> +
>>> +const PropertyInfo qdev_prop_link_array =
>>> + DEFINE_PROP_ARRAY_INFO(qdev_prop_link, void *, NULL);
>>
>> It could use &strList_type_info, since qdev_prop_link uses
>> &str_type_info and serialize as object-path strings.
>
> Point.
qdev_prop_link's .qapi_type = &str_type_info is actually useless.
qdev_prop_link has .create = create_link_property, and
create_link_property() doesn't use prop->qapi_type. It wraps around
object_class_property_add_link(), which passes null @qapi_type to
object_class_property_add().
I'll post a patch to make link and child property creation use
&str_type_info.
Once we have that, this patch can use &strList_type_info for
qdev_prop_link_array.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-05 7:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 8:38 [PATCH 0/2] qdev: Typed array properties for better QOM introspection Markus Armbruster
2026-11-04 8:38 ` [PATCH 1/2] qdev: Convert array properties to QAPI-aware registration Markus Armbruster
2026-11-04 10:27 ` marcandre.lureau
2026-11-05 6:47 ` Markus Armbruster
2026-11-05 7:35 ` Markus Armbruster
2026-11-04 8:38 ` [PATCH 2/2] qdev: Remove unused DEFINE_PROP_ARRAY parameter _arraytype Markus Armbruster
2026-11-04 8:40 ` [PATCH 0/2] qdev: Typed array properties for better QOM introspection Markus Armbruster
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.