Patchwork [RFC,12/15] create qemu_global_get() function

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

Comments

Eduardo Habkost - Aug. 7, 2012, 7:56 p.m.
Useful for cases where code is not converted to QOM and/or QDEV yet, but
needs to check the value of a global property.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 global-properties.c | 11 +++++++++++
 hw/qdev.h           |  8 ++++++++
 2 files changed, 19 insertions(+)

Patch

diff --git a/global-properties.c b/global-properties.c
index 20a838c..0c3d1b6 100644
--- a/global-properties.c
+++ b/global-properties.c
@@ -49,6 +49,17 @@  static void object_set_globals(Object *obj,
     } while (class);
 }
 
+const char *qemu_global_get(const char *driver, const char *property)
+{
+    GlobalProperty *prop;
+    QTAILQ_FOREACH(prop, &global_props, next) {
+        if (!strcmp(prop->driver, driver) && !strcmp(prop->property, property)) {
+            return prop->value;
+        }
+    }
+    return NULL;
+}
+
 void qdev_prop_set_globals(DeviceState *dev)
 {
     return object_set_globals(OBJECT(dev), qdev_global_parse);
diff --git a/hw/qdev.h b/hw/qdev.h
index 5941cae..d3210d8 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -337,6 +337,14 @@  void qemu_globals_register_list(GlobalProperty *props);
 void qdev_prop_set_globals(DeviceState *dev);
 void object_prop_set_globals(Object *obj);
 
+/* Get the string value of a global property directly
+ *
+ * Using this function is discouraged. Code should be converted to use
+ * QOM and/or qdev instead of using it. It is provided only as a convenience
+ * for code that is not converted yet.
+ */
+const char *qemu_global_get(const char *driver, const char *property);
+
 char *qdev_get_fw_dev_path(DeviceState *dev);
 
 /**