qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 4/5] qdev/class: helper function to get a list of dr


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH 4/5] qdev/class: helper function to get a list of drivers.
Date: Thu, 9 Jul 2009 15:02:23 +0200

Signed-off-by: Gerd Hoffmann <address@hidden>
---
 hw/qdev.c |   17 +++++++++++++++++
 hw/qdev.h |    2 ++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 67cca3b..baa7d16 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -88,6 +88,23 @@ DeviceInfo *qdev_find_info(BusInfo *bus_info, const char 
*name, DeviceClass clas
     return NULL;
 }
 
+size_t qdev_list_devices(BusInfo *bus_info, DeviceClass class,
+                         char *dest, size_t len)
+{
+    DeviceInfo *info;
+    size_t pos = 0;
+
+    for (info = device_info_list; info != NULL; info = info->next) {
+        if (bus_info && info->bus_info != bus_info)
+            continue;
+        if (class && info->class != class)
+            continue;
+        pos += snprintf(dest+pos, len-pos, "%s%s", pos ? "," : "",
+                        info->alias ? info->alias : info->name);
+    }
+    return pos;
+}
+
 /* Create a new device.  This only initializes the device state structure
    and allows properties to be set.  qdev_init should be called to
    initialize the actual device emulation.  */
diff --git a/hw/qdev.h b/hw/qdev.h
index a35b712..3203a3e 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -103,6 +103,8 @@ struct DeviceInfo {
 void qdev_register(DeviceInfo *info);
 const char *qdev_class_name(DeviceClass class);
 DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name, DeviceClass 
class);
+size_t qdev_list_devices(BusInfo *bus_info, DeviceClass class,
+                         char *dest, size_t len);
 
 /* Register device properties.  */
 /* GPIO inputs also double as IRQ sinks.  */
-- 
1.6.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]