diff mbox series

[PULL,55/59] qapi/qmp: add ObjectPropertyInfo.default-value

Message ID 1579787449-27599-56-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,01/59] cpu: Introduce cpu_class_set_parent_reset() | expand

Commit Message

Paolo Bonzini Jan. 23, 2020, 1:50 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Report the default value associated with a property.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20200110153039.1379601-26-marcandre.lureau@redhat.com>
[Report it as type "any", not string. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qapi/qom.json      | 7 ++++++-
 qom/qom-qmp-cmds.c | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/qapi/qom.json b/qapi/qom.json
index 32db96f..1e3c2ad 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -26,10 +26,15 @@ 
 #
 # @description: if specified, the description of the property.
 #
+# @default-value: the default value, if any (since 5.0)
+#
 # Since: 1.2
 ##
 { 'struct': 'ObjectPropertyInfo',
-  'data': { 'name': 'str', 'type': 'str', '*description': 'str' } }
+  'data': { 'name': 'str',
+            'type': 'str',
+            '*description': 'str',
+            '*default-value': 'any' } }
 
 ##
 # @qom-list:
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 8785816..6136efe 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -177,6 +177,8 @@  ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,
         info->type = g_strdup(prop->type);
         info->has_description = !!prop->description;
         info->description = g_strdup(prop->description);
+        info->default_value = qobject_ref(prop->defval);
+        info->has_default_value = !!info->default_value;
 
         entry = g_malloc0(sizeof(*entry));
         entry->value = info;