qom/object.c: add object_class_property_add_uint8_ptr()
This adds a class property that references a uint8_t within the object instance and is intended to be a replacement for object_property_add_uint8_ptr(). This commit also removes the __attribute__((unused)) annotation from object_class_prop_ptr() which is no longer required now that the previous defined DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() is now being used. 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-5-mark.caveayland@nutanix.com>
Mark Cave-Ayland committed
Aug 25, 2026 at 14:41 UTC
d817fa0c2ed37af8e0146797790f3fd0b84bf58a
2 files changed
+40
-1
include/qom/object.h
+18
@@ -2033,6 +2033,24 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
2033
const uint8_t *v,
2034
ObjectPropertyFlags flags);
2035
2036
+/**
2037
+ * object_class_property_add_uint8_ptr:
2038
+ * @klass: the object class to add a property to
2039
+ * @name: the name of the property
2040
+ * @offset: the offset from the object instance where the uint8 value is
2041
+ * stored
2042
+ * @flags: bitwise-or'd ObjectPropertyFlags
2043
+ *
2044
+ * Add an integer property in memory. This function will add a
2045
+ * property of type 'uint8'.
2046
+ *
2047
+ * Returns: The newly added property on success, or %NULL on failure.
2048
+ */
2049
+ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
2050
+ const char *name,
2051
+ ptrdiff_t offset,
2052
+ ObjectPropertyFlags flags);
2053
+
2054
/**
2055
* object_class_static_property_add_uint8_ptr:
2056
* @klass: the object class to add a static property to
qom/object.c
+22
-1
@@ -2703,7 +2703,6 @@ DEFINE_OBJECT_PROPERTY_SCALAR_METHODS(uint64)
2703
#undef DEFINE_OBJECT_PROPERTY_SCALAR_METHODS
2704
2705
2706
-__attribute__((unused))
2706
static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
2707
{
2708
void *ptr = obj;
@@ -2742,6 +2741,8 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
2741
OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
2742
OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
2743
2744
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
2745
+
2746
#undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
2747
#undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
2748
#undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
@@ -2767,6 +2768,26 @@ object_property_add_uint8_ptr(Object *obj, const char *name,
2768
getter, setter, NULL, (void *)v);
2769
}
2770
2771
+ObjectProperty *
2772
+object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
2773
+ ptrdiff_t offset,
2774
+ ObjectPropertyFlags flags)
2775
+{
2776
+ ObjectPropertyAccessor *getter = NULL;
2777
+ ObjectPropertyAccessor *setter = NULL;
2778
+
2779
+ if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
2780
+ getter = property_class_get_uint8_ptr;
2781
+ }
2782
+
2783
+ if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
2784
+ setter = property_class_set_uint8_ptr;
2785
+ }
2786
+
2787
+ return object_class_property_add(klass, name, "uint8",
2788
+ getter, setter, NULL, (void *)offset);
2789
+}
2790
+
2791
ObjectProperty *
2792
object_class_static_property_add_uint8_ptr(ObjectClass *klass,
2793
const char *name,