From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MOtGl-00027G-Gr for qemu-devel@nongnu.org; Thu, 09 Jul 2009 09:02:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MOtGg-00025Y-T6 for qemu-devel@nongnu.org; Thu, 09 Jul 2009 09:02:34 -0400 Received: from [199.232.76.173] (port=42380 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOtGg-00025R-Jh for qemu-devel@nongnu.org; Thu, 09 Jul 2009 09:02:30 -0400 Received: from mx2.redhat.com ([66.187.237.31]:54492) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MOtGf-0002As-By for qemu-devel@nongnu.org; Thu, 09 Jul 2009 09:02:29 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n69D2SmE016201 for ; Thu, 9 Jul 2009 09:02:28 -0400 From: Gerd Hoffmann Date: Thu, 9 Jul 2009 15:02:23 +0200 Message-Id: <1247144544-8885-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1247144544-8885-1-git-send-email-kraxel@redhat.com> References: <1247144544-8885-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 4/5] qdev/class: helper function to get a list of drivers. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- 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