qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2] Show values and description when using "qom-list


From: Ricardo Perez Blanco
Subject: [Qemu-devel] [PATCH v2] Show values and description when using "qom-list"
Date: Fri, 1 Jun 2018 17:39:22 +0200

For debugging purposes it is very useful to:
 - See the description of the field. This information is already filled
   in but not shown in "qom-list" command.
 - Display value of the field.

Signed-off-by: Ricardo Perez Blanco <address@hidden>
---
 hmp.c          | 13 +++++++++++--
 qapi/misc.json |  6 ++++--
 qmp.c          |  7 +++++++
 qom/object.c   |  8 +++-----
 4 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/hmp.c b/hmp.c
index a25c7bd9a8..ff3a024cd0 100644
--- a/hmp.c
+++ b/hmp.c
@@ -2490,8 +2490,17 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
         while (list != NULL) {
             ObjectPropertyInfo *value = list->value;
 
-            monitor_printf(mon, "%s (%s)\n",
-                           value->name, value->type);
+            monitor_printf(mon, "%s", value->name);
+            if (value->has_value) {
+                monitor_printf(mon, "=%s", value->value);
+            }
+            monitor_printf(mon, " (%s)", value->type);
+            if (value->has_description) {
+                monitor_printf(mon, "\r\t\t\t\t\t\t\t\t\t[Description: %s]",
+                               value->description);
+            }
+            monitor_printf(mon, "\n");
+
             list = list->next;
         }
         qapi_free_ObjectPropertyInfoList(start);
diff --git a/qapi/misc.json b/qapi/misc.json
index 5636f4a149..b4bc472a37 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -1328,10 +1328,12 @@
 #
 # @description: if specified, the description of the property.
 #
-# Since: 1.2
+# @value: if specified, the value of the property.
+#
+# Since: 2.13
 ##
 { 'struct': 'ObjectPropertyInfo',
-  'data': { 'name': 'str', 'type': 'str', '*description': 'str' } }
+  'data': { 'name': 'str', 'type': 'str', '*description': 'str', '*value': 
'str' } }
 
 ##
 # @qom-list:
diff --git a/qmp.c b/qmp.c
index f72261667f..39cf656f97 100644
--- a/qmp.c
+++ b/qmp.c
@@ -237,6 +237,13 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, 
Error **errp)
 
         entry->value->name = g_strdup(prop->name);
         entry->value->type = g_strdup(prop->type);
+        if (prop->description) {
+            entry->value->has_description = true;
+            entry->value->description = g_strdup(prop->description);
+        }
+        entry->value->has_value = true;
+        entry->value->value = g_strdup(object_property_print(obj,
+                                 entry->value->name, true, errp));
     }
 
     return props;
diff --git a/qom/object.c b/qom/object.c
index 467795189c..4d1606e5f9 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1359,13 +1359,11 @@ char *object_property_print(Object *obj, const char 
*name, bool human,
     v = string_output_visitor_new(human, &string);
     object_property_get(obj, v, name, &local_err);
     if (local_err) {
-        error_propagate(errp, local_err);
-        goto out;
+        string = g_strdup("<Error reading value>");
+    } else {
+        visit_complete(v, &string);
     }
 
-    visit_complete(v, &string);
-
-out:
     visit_free(v);
     return string;
 }
-- 
2.16.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]