Patchwork [RFC,V1,06/14] qdev: Added fn for querying device property types

login
register
mail settings
Submitter Peter A. G. Crosthwaite
Date Aug. 25, 2011, 6:41 a.m.
Message ID <1314254480-22438-7-git-send-email-peter.crosthwaite@petalogix.com>
Download mbox | patch
Permalink /patch/111471/
State New
Headers show

Comments

Peter A. G. Crosthwaite - Aug. 25, 2011, 6:41 a.m.
Added a function qdev_get_prop_type(), which allows a machine model to
query the type of a qdev prop of a device using a handle to the device,
and the string name of the property

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
---
 hw/qdev-properties.c |    9 +++++++++
 hw/qdev.h            |    1 +
 2 files changed, 10 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 0c0c292..b5b2a78 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -583,6 +583,15 @@  int qdev_prop_exists(DeviceState *dev, const char *name)
     return qdev_prop_find(dev, name) ? true : false;
 }
 
+int qdev_prop_get_type(DeviceState *dev, const char *name, enum PropertyType *ret)
+{
+    Property *prop = qdev_prop_find(dev, name);
+    if (!prop)
+        return 1;
+    *ret = prop->info->type;
+    return 0;
+}
+
 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
 {
     Property *prop;
diff --git a/hw/qdev.h b/hw/qdev.h
index 8a13ec9..79d9f9d 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -295,6 +295,7 @@  extern PropertyInfo qdev_prop_pci_devfn;
 /* Set properties between creation and init.  */
 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
 int qdev_prop_exists(DeviceState *dev, const char *name);
+int qdev_prop_get_type(DeviceState *dev, const char *name, enum PropertyType *ret);
 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
 void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type);
 void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);