aboutsummaryrefslogtreecommitdiffstats
path: root/hw/qdev.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-07-29 13:12:23 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-30 09:50:37 -0500
commit1b524b044160ca1c508c4f3ac9ae5b93600851fd (patch)
tree17621484ded2787343793a8fcc55d8206d8d37e8 /hw/qdev.c
parent213189ab65d83ecd9072f27c80a15dcb91b6bdbf (diff)
qdev: factor out qdev_print_devinfo.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r--hw/qdev.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index 479eb72b6..6f05232f7 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;
}