Signed-off-by: Andrzej Zaborowski<address@hidden>
---
There are other ways to do this, but adding an API for querying
available qdev drivers was the one that made most sense to me.
---
hw/qdev.c | 38 ++++++++++++++++++++++++++++++++++++++
hw/qdev.h | 7 +++++++
monitor.c | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index d0cf66d..ba97312 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -1535,3 +1535,41 @@ void qdev_machine_init(void)
qdev_get_peripheral_anon();
qdev_get_peripheral();
}
+
+int qdev_driver_foreach(qdev_driver_foreach_func func, void *opaque)
+{
+ DeviceInfo *info;
+ int ret = 0;
+
+ for (info = device_info_list; info != NULL; info = info->next) {
+ ret |= (*func)(info, opaque);
+ }
+
+ return ret;
+}
+
+int qdev_driver_prop_foreach(qdev_driver_prop_foreach_func func,
+ const char *driver, void *opaque)
+{
+ DeviceInfo *info;
+ Property *prop;
+ int ret = 0;
+
+ info = qdev_find_info(NULL, driver);
+ if (!info) {
+ return -1;
+ }
+
+ for (prop = info->props; prop&& prop->name; prop++) {
+ /*
+ * TODO Properties without a parser are just for dirty hacks.
+ * See comment in qdev_device_help.
+ */
+ if (!prop->info->parse) {
+ continue; /* no way to set it, don't show */
+ }
+ ret |= (*func)(prop, opaque);