Patchwork [RFC,09/15] isolate qdev-independent parts of qdev_prop_set_globals()

login
register
mail settings
Submitter Eduardo Habkost
Date Aug. 7, 2012, 7:56 p.m.
Message ID <1344369413-9053-10-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/175778/
State New
Headers show

Comments

Eduardo Habkost - Aug. 7, 2012, 7:56 p.m.
Create a qdev-independent function, and use a callback that calls
qdev_prop_parse().

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 global-properties.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

Patch

diff --git a/global-properties.c b/global-properties.c
index a1c3581..d99bcee 100644
--- a/global-properties.c
+++ b/global-properties.c
@@ -17,9 +17,20 @@  void qdev_prop_register_global_list(GlobalProperty *props)
     }
 }
 
-void qdev_prop_set_globals(DeviceState *dev)
+static void qdev_global_parse(Object *obj, const char *property,
+                              const char *value, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    qdev_prop_parse(dev, property, value, errp);
+}
+
+static void object_set_globals(Object *obj,
+                               void (*parse_fn)(Object *obj,
+                                                const char *property,
+                                                const char *value,
+                                                Error **errp))
 {
-    ObjectClass *class = object_get_class(OBJECT(dev));
+    ObjectClass *class = object_get_class(obj);
 
     do {
         GlobalProperty *prop;
@@ -28,7 +39,7 @@  void qdev_prop_set_globals(DeviceState *dev)
             if (strcmp(object_class_get_name(class), prop->driver) != 0) {
                 continue;
             }
-            qdev_prop_parse(dev, prop->property, prop->value, &err);
+            parse_fn(obj, prop->property, prop->value, &err);
             if (err) {
                 qerror_report_err(err);
                 exit(1);
@@ -38,6 +49,11 @@  void qdev_prop_set_globals(DeviceState *dev)
     } while (class);
 }
 
+void qdev_prop_set_globals(DeviceState *dev)
+{
+    return object_set_globals(OBJECT(dev), qdev_global_parse);
+}
+
 static int qdev_add_one_global(QemuOpts *opts, void *opaque)
 {
     GlobalProperty *g;