Patchwork [RFC,08/15] move global properties code to global-properties.c

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

Comments

Eduardo Habkost - Aug. 7, 2012, 7:56 p.m.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.objs        |  1 +
 global-properties.c  | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev-properties.c | 54 --------------------------------------------------
 3 files changed, 57 insertions(+), 54 deletions(-)
 create mode 100644 global-properties.c

Patch

diff --git a/Makefile.objs b/Makefile.objs
index 5ebbcfa..5cd4082 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -77,6 +77,7 @@  common-obj-y += qemu-char.o #aio.o
 common-obj-y += block-migration.o iohandler.o
 common-obj-y += pflib.o
 common-obj-y += bitmap.o bitops.o
+common-obj-y += global-properties.o
 
 common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
 common-obj-$(CONFIG_WIN32) += version.o
diff --git a/global-properties.c b/global-properties.c
new file mode 100644
index 0000000..a1c3581
--- /dev/null
+++ b/global-properties.c
@@ -0,0 +1,56 @@ 
+#include "hw/qdev.h"
+#include "qerror.h"
+
+static QTAILQ_HEAD(, GlobalProperty) global_props = QTAILQ_HEAD_INITIALIZER(global_props);
+
+static void qdev_prop_register_global(GlobalProperty *prop)
+{
+    QTAILQ_INSERT_TAIL(&global_props, prop, next);
+}
+
+void qdev_prop_register_global_list(GlobalProperty *props)
+{
+    int i;
+
+    for (i = 0; props[i].driver != NULL; i++) {
+        qdev_prop_register_global(props+i);
+    }
+}
+
+void qdev_prop_set_globals(DeviceState *dev)
+{
+    ObjectClass *class = object_get_class(OBJECT(dev));
+
+    do {
+        GlobalProperty *prop;
+        Error *err = NULL;
+        QTAILQ_FOREACH(prop, &global_props, next) {
+            if (strcmp(object_class_get_name(class), prop->driver) != 0) {
+                continue;
+            }
+            qdev_prop_parse(dev, prop->property, prop->value, &err);
+            if (err) {
+                qerror_report_err(err);
+                exit(1);
+            }
+        }
+        class = object_class_get_parent(class);
+    } while (class);
+}
+
+static int qdev_add_one_global(QemuOpts *opts, void *opaque)
+{
+    GlobalProperty *g;
+
+    g = g_malloc0(sizeof(*g));
+    g->driver   = qemu_opt_get(opts, "driver");
+    g->property = qemu_opt_get(opts, "property");
+    g->value    = qemu_opt_get(opts, "value");
+    qdev_prop_register_global(g);
+    return 0;
+}
+
+void qemu_add_globals(void)
+{
+    qemu_opts_foreach(qemu_find_opts("global"), qdev_add_one_global, NULL, 0);
+}
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index a52884f..3217490 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -1219,57 +1219,3 @@  void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
     ptr = qdev_get_prop_ptr(dev, prop);
     *ptr = value;
 }
-
-static QTAILQ_HEAD(, GlobalProperty) global_props = QTAILQ_HEAD_INITIALIZER(global_props);
-
-static void qdev_prop_register_global(GlobalProperty *prop)
-{
-    QTAILQ_INSERT_TAIL(&global_props, prop, next);
-}
-
-void qdev_prop_register_global_list(GlobalProperty *props)
-{
-    int i;
-
-    for (i = 0; props[i].driver != NULL; i++) {
-        qdev_prop_register_global(props+i);
-    }
-}
-
-void qdev_prop_set_globals(DeviceState *dev)
-{
-    ObjectClass *class = object_get_class(OBJECT(dev));
-
-    do {
-        GlobalProperty *prop;
-        Error *err = NULL;
-        QTAILQ_FOREACH(prop, &global_props, next) {
-            if (strcmp(object_class_get_name(class), prop->driver) != 0) {
-                continue;
-            }
-            qdev_prop_parse(dev, prop->property, prop->value, &err);
-            if (err) {
-                qerror_report_err(err);
-                exit(1);
-            }
-        }
-        class = object_class_get_parent(class);
-    } while (class);
-}
-
-static int qdev_add_one_global(QemuOpts *opts, void *opaque)
-{
-    GlobalProperty *g;
-
-    g = g_malloc0(sizeof(*g));
-    g->driver   = qemu_opt_get(opts, "driver");
-    g->property = qemu_opt_get(opts, "property");
-    g->value    = qemu_opt_get(opts, "value");
-    qdev_prop_register_global(g);
-    return 0;
-}
-
-void qemu_add_globals(void)
-{
-    qemu_opts_foreach(qemu_find_opts("global"), qdev_add_one_global, NULL, 0);
-}