summaryrefslogtreecommitdiffstats
path: root/include/qom
diff options
context:
space:
mode:
authorMarc-André Lureau2020-01-10 16:30:23 +0100
committerPaolo Bonzini2020-01-24 20:59:13 +0100
commit0e76ed0a5da4c8540597c1ffac72705e04323f69 (patch)
tree6a5daf73b26ed25d72cc329ac23c29173d1905df /include/qom
parentqstring: add qstring_free() (diff)
downloadqemu-0e76ed0a5da4c8540597c1ffac72705e04323f69.tar.gz
qemu-0e76ed0a5da4c8540597c1ffac72705e04323f69.tar.xz
qemu-0e76ed0a5da4c8540597c1ffac72705e04323f69.zip
object: add object_property_set_default
Add a default value to ObjectProperty and an implementation of ObjectPropertyInit that uses it. This will make it easier to show the default in help messages. Also provide convenience functions object_property_set_default_{bool, str, int, uint}(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200110153039.1379601-11-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qom')
-rw-r--r--include/qom/object.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/qom/object.h b/include/qom/object.h
index afe658c969..82cf20f441 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -378,6 +378,7 @@ struct ObjectProperty
ObjectPropertyRelease *release;
ObjectPropertyInit *init;
void *opaque;
+ QObject *defval;
};
/**
@@ -1056,6 +1057,42 @@ ObjectProperty *object_class_property_add(ObjectClass *klass, const char *name,
void *opaque, Error **errp);
/**
+ * object_property_set_default_bool:
+ * @prop: the property to set
+ * @value: the value to be written to the property
+ *
+ * Set the property default value.
+ */
+void object_property_set_default_bool(ObjectProperty *prop, bool value);
+
+/**
+ * object_property_set_default_str:
+ * @prop: the property to set
+ * @value: the value to be written to the property
+ *
+ * Set the property default value.
+ */
+void object_property_set_default_str(ObjectProperty *prop, const char *value);
+
+/**
+ * object_property_set_default_int:
+ * @prop: the property to set
+ * @value: the value to be written to the property
+ *
+ * Set the property default value.
+ */
+void object_property_set_default_int(ObjectProperty *prop, int64_t value);
+
+/**
+ * object_property_set_default_uint:
+ * @prop: the property to set
+ * @value: the value to be written to the property
+ *
+ * Set the property default value.
+ */
+void object_property_set_default_uint(ObjectProperty *prop, uint64_t value);
+
+/**
* object_property_find:
* @obj: the object
* @name: the name of the property