qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
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	[thread overview]
Message-ID: <1247144544-8885-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1247144544-8885-1-git-send-email-kraxel@redhat.com>


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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

  parent reply	other threads:[~2009-07-09 13:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-09 13:02 [Qemu-devel] [PATCH 0/5] qdev: add driver class support Gerd Hoffmann
2009-07-09 13:02 ` [Qemu-devel] [PATCH 1/5] qdev/class: core Gerd Hoffmann
2009-07-09 13:02 ` [Qemu-devel] [PATCH 2/5] qdev/class: tag sound Gerd Hoffmann
2009-07-09 13:02 ` [Qemu-devel] [PATCH 3/5] qdev/class: tag network Gerd Hoffmann
2009-07-09 13:02 ` Gerd Hoffmann [this message]
2009-07-09 13:02 ` [Qemu-devel] [PATCH 5/5] qdev/class: make pci_nic_init() use qdev's device list Gerd Hoffmann
2009-07-09 13:19 ` [Qemu-devel] [PATCH 0/5] qdev: add driver class support Paul Brook
2009-07-09 13:39   ` Gerd Hoffmann
2009-07-09 13:48     ` Paul Brook
2009-07-09 14:26       ` Gerd Hoffmann
2009-07-09 15:46         ` Anthony Liguori
2009-07-10  7:50           ` Gerd Hoffmann
2009-07-10  9:46             ` Paul Brook
2009-07-10  9:59               ` Gerd Hoffmann
2009-07-10 10:13                 ` Paul Brook
2009-07-10 10:29                   ` Gerd Hoffmann
2009-07-09 14:34   ` Filip Navara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1247144544-8885-5-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).