@@ -1815,6 +1815,29 @@ ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
ptrdiff_t offset,
ObjectPropertyFlags flags);
+/**
+ * object_property_add_bool_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 bool property in memory. This function will add a
+ * property of type 'bool'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *
+object_property_add_bool_ptr(Object *obj, const char *name,
+ bool *v,
+ ObjectPropertyFlags flags);
+
+ObjectProperty *
+object_class_property_add_bool_ptr(ObjectClass *klass,
+ const char *name,
+ ptrdiff_t offset,
+ ObjectPropertyFlags flags);
+
/**
* object_property_add_alias:
* @obj: the object to add a property to
@@ -2713,6 +2713,37 @@ object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
flags, offset);
}
+static void property_visit_bool_ptr(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ PointerProperty *prop = opaque;
+ bool *field = pointer_property_get_ptr(obj, prop);
+ visit_type_bool(v, name, field, errp);
+}
+
+ObjectProperty *
+object_property_add_bool_ptr(Object *obj, const char *name,
+ bool *v,
+ ObjectPropertyFlags flags)
+{
+ return object_property_add_uint_ptr(obj, name, "bool",
+ property_visit_bool_ptr,
+ property_visit_bool_ptr,
+ flags,
+ (void *)v);
+}
+
+ObjectProperty *
+object_class_property_add_bool_ptr(ObjectClass *klass, const char *name,
+ ptrdiff_t offset,
+ ObjectPropertyFlags flags)
+{
+ return object_class_property_add_uint_ptr(klass, name, "bool",
+ property_visit_bool_ptr,
+ property_visit_bool_ptr,
+ flags, offset);
+}
+
typedef struct {
Object *target_obj;
char *target_name;
Provide helpers for registering boolean properties that simply read/write a struct field, to reduce the need to manually write property getters and setters. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Daniel P. Berrangé" <berrange@redhat.com> Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: qemu-devel@nongnu.org --- include/qom/object.h | 23 +++++++++++++++++++++++ qom/object.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)