Commit d817fa0c2e for qemu.org
commit d817fa0c2ed37af8e0146797790f3fd0b84bf58a
Author: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Date: Tue Aug 25 14:41:25 2026 +0100
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>
diff --git a/include/qom/object.h b/include/qom/object.h
index 11b1c9d2dc..eba675d218 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2033,6 +2033,24 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
const uint8_t *v,
ObjectPropertyFlags flags);
+/**
+ * object_class_property_add_uint8_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 uint8 value is
+ * stored
+ * @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_class_property_add_uint8_ptr(ObjectClass *klass,
+ const char *name,
+ ptrdiff_t offset,
+ ObjectPropertyFlags flags);
+
/**
* object_class_static_property_add_uint8_ptr:
* @klass: the object class to add a static property to
diff --git a/qom/object.c b/qom/object.c
index 9cb2cae4a7..a480fdd400 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2703,7 +2703,6 @@ DEFINE_OBJECT_PROPERTY_SCALAR_METHODS(uint64)
#undef DEFINE_OBJECT_PROPERTY_SCALAR_METHODS
-__attribute__((unused))
static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
{
void *ptr = obj;
@@ -2742,6 +2741,8 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+
#undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
#undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
#undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
@@ -2767,6 +2768,26 @@ object_property_add_uint8_ptr(Object *obj, const char *name,
getter, setter, NULL, (void *)v);
}
+ObjectProperty *
+object_class_property_add_uint8_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_uint8_ptr;
+ }
+
+ if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+ setter = property_class_set_uint8_ptr;
+ }
+
+ return object_class_property_add(klass, name, "uint8",
+ getter, setter, NULL, (void *)offset);
+}
+
ObjectProperty *
object_class_static_property_add_uint8_ptr(ObjectClass *klass,
const char *name,