qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v3 3/5] vl: convert machine help to use object_prope


From: Daniel P. Berrange
Subject: [Qemu-devel] [PATCH v3 3/5] vl: convert machine help to use object_property_foreach
Date: Thu, 8 Oct 2015 15:09:02 +0100

Rather than directly traversing the object property list,
use the object_property_foreach iterator. This removes a
dependancy on the implementation approach for properties.

Signed-off-by: Daniel P. Berrange <address@hidden>
---
 vl.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/vl.c b/vl.c
index f2bd8d2..a29fb82 100644
--- a/vl.c
+++ b/vl.c
@@ -1511,27 +1511,34 @@ MachineInfoList *qmp_query_machines(Error **errp)
     return mach_list;
 }
 
-static int machine_help_func(QemuOpts *opts, MachineState *machine)
+
+static void machine_help_func_iter(Object *obj,
+                                   ObjectProperty *prop,
+                                   Error **errp,
+                                   void *opaque)
 {
-    ObjectProperty *prop;
+    MachineState *machine = MACHINE(obj);
+    if (!prop->set) {
+        return;
+    }
+
+    error_printf("%s.%s=%s", MACHINE_GET_CLASS(machine)->name,
+                 prop->name, prop->type);
+    if (prop->description) {
+        error_printf(" (%s)\n", prop->description);
+    } else {
+        error_printf("\n");
+    }
+}
 
+static int machine_help_func(QemuOpts *opts, MachineState *machine)
+{
     if (!qemu_opt_has_help_opt(opts)) {
         return 0;
     }
 
-    QTAILQ_FOREACH(prop, &OBJECT(machine)->properties, node) {
-        if (!prop->set) {
-            continue;
-        }
-
-        error_printf("%s.%s=%s", MACHINE_GET_CLASS(machine)->name,
-                     prop->name, prop->type);
-        if (prop->description) {
-            error_printf(" (%s)\n", prop->description);
-        } else {
-            error_printf("\n");
-        }
-    }
+    object_property_foreach(OBJECT(machine),
+                            machine_help_func_iter, NULL, NULL);
 
     return 1;
 }
-- 
2.4.3




reply via email to

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