From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlO2D-0006K6-CG for qemu-devel@nongnu.org; Thu, 12 Jan 2012 12:01:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlO28-0006nl-FG for qemu-devel@nongnu.org; Thu, 12 Jan 2012 12:01:53 -0500 Received: from mail-gy0-f173.google.com ([209.85.160.173]:55958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlO28-0006ne-CB for qemu-devel@nongnu.org; Thu, 12 Jan 2012 12:01:48 -0500 Received: by ghbg15 with SMTP id g15so468291ghb.4 for ; Thu, 12 Jan 2012 09:01:47 -0800 (PST) Message-ID: <4F0F11F7.9080202@codemonkey.ws> Date: Thu, 12 Jan 2012 11:01:43 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1326036534-18029-1-git-send-email-balrogg@gmail.com> In-Reply-To: <1326036534-18029-1-git-send-email-balrogg@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Add tab-completion for device_add. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrzej Zaborowski Cc: qemu-devel@nongnu.org On 01/08/2012 09:28 AM, Andrzej Zaborowski wrote: > Signed-off-by: Andrzej Zaborowski > --- > 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); Would be better to pass prop->name here as Property is going to go away soon. Regards, Anthony Liguori