From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MW75J-0002Jm-NQ for qemu-devel@nongnu.org; Wed, 29 Jul 2009 07:12:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MW75E-00027M-7Q for qemu-devel@nongnu.org; Wed, 29 Jul 2009 07:12:36 -0400 Received: from [199.232.76.173] (port=60411 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MW75E-00026n-19 for qemu-devel@nongnu.org; Wed, 29 Jul 2009 07:12:32 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49644) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MW75D-0007vV-FV for qemu-devel@nongnu.org; Wed, 29 Jul 2009 07:12:31 -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 n6TBCUiF027215 for ; Wed, 29 Jul 2009 07:12:30 -0400 From: Gerd Hoffmann Date: Wed, 29 Jul 2009 13:12:23 +0200 Message-Id: <1248865944-15937-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] qdev: factor out qdev_print_devinfo. 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 | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 479eb72..6f05232 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -105,6 +105,21 @@ DeviceState *qdev_create(BusState *bus, const char *name) return dev; } +static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len) +{ + int pos = 0; + + pos += snprintf(dest+pos, len-pos, "name \"%s\", bus %s", + info->name, info->bus_info->name); + if (info->alias) + pos += snprintf(dest+pos, len-pos, ", alias \"%s\"", info->alias); + if (info->desc) + pos += snprintf(dest+pos, len-pos, ", desc \"%s\"", info->desc); + if (info->no_user) + pos += snprintf(dest+pos, len-pos, ", no-user"); + return pos; +} + DeviceState *qdev_device_add(const char *cmdline) { DeviceInfo *info; @@ -120,8 +135,10 @@ DeviceState *qdev_device_add(const char *cmdline) return NULL; } if (strcmp(driver, "?") == 0) { + char msg[256]; for (info = device_info_list; info != NULL; info = info->next) { - fprintf(stderr, "name \"%s\", bus %s\n", info->name, info->bus_info->name); + qdev_print_devinfo(info, msg, sizeof(msg)); + fprintf(stderr, "%s\n", msg); } return NULL; } -- 1.6.2.5