@samitouri / QOSamiQemu / commits / 99da68c06f

qom/object.c: add object_class_property_add_uint32_ptr()

This adds a class property that references a uint32_t within the object instance and is intended to be a replacement for object_property_add_uint32_ptr(). Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20260825134320.1039012-9-mark.caveayland@nutanix.com>

Mark Cave-Ayland committed Aug 25, 2026 at 14:41 UTC 99da68c06f1731801075a07b9932e38fb96484a6
2 files changed +39
include/qom/object.h
+18
@@ -2129,6 +2129,24 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
2129 const uint32_t *v,
2130 ObjectPropertyFlags flags);
2131
2132 +/**
2133 + * object_class_property_add_uint32_ptr:
2134 + * @klass: the object class to add a property to
2135 + * @name: the name of the property
2136 + * @offset: the offset from the object instance where the uint32 value is
2137 + * stored
2138 + * @flags: bitwise-or'd ObjectPropertyFlags
2139 + *
2140 + * Add an integer property in memory. This function will add a
2141 + * property of type 'uint32'.
2142 + *
2143 + * Returns: The newly added property on success, or %NULL on failure.
2144 + */
2145 +ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
2146 + const char *name,
2147 + ptrdiff_t offset,
2148 + ObjectPropertyFlags flags);
2149 +
2150 /**
2151 * object_class_static_property_add_uint32_ptr:
2152 * @klass: the object class to add a static property to
qom/object.c
+21
@@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
2742 OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
2743
2744 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
2745 +DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint32)
2746 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
2747
2748 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
@@ -2871,6 +2872,26 @@ object_property_add_uint32_ptr(Object *obj, const char *name,
2872 getter, setter, NULL, (void *)v);
2873 }
2874
2875 +ObjectProperty *
2876 +object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
2877 + ptrdiff_t offset,
2878 + ObjectPropertyFlags flags)
2879 +{
2880 + ObjectPropertyAccessor *getter = NULL;
2881 + ObjectPropertyAccessor *setter = NULL;
2882 +
2883 + if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
2884 + getter = property_class_get_uint32_ptr;
2885 + }
2886 +
2887 + if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
2888 + setter = property_class_set_uint32_ptr;
2889 + }
2890 +
2891 + return object_class_property_add(klass, name, "uint32",
2892 + getter, setter, NULL, (void *)offset);
2893 +}
2894 +
2895 ObjectProperty *
2896 object_class_static_property_add_uint32_ptr(ObjectClass *klass,
2897 const char *name,