Commit 1b524b044160ca1c508c4f3ac9ae5b93600851fd
Committed by
Anthony Liguori
1 parent
213189ab
qdev: factor out qdev_print_devinfo.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
18 additions
and
1 deletions
hw/qdev.c
| ... | ... | @@ -105,6 +105,21 @@ DeviceState *qdev_create(BusState *bus, const char *name) |
| 105 | 105 | return dev; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | +static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len) | |
| 109 | +{ | |
| 110 | + int pos = 0; | |
| 111 | + | |
| 112 | + pos += snprintf(dest+pos, len-pos, "name \"%s\", bus %s", | |
| 113 | + info->name, info->bus_info->name); | |
| 114 | + if (info->alias) | |
| 115 | + pos += snprintf(dest+pos, len-pos, ", alias \"%s\"", info->alias); | |
| 116 | + if (info->desc) | |
| 117 | + pos += snprintf(dest+pos, len-pos, ", desc \"%s\"", info->desc); | |
| 118 | + if (info->no_user) | |
| 119 | + pos += snprintf(dest+pos, len-pos, ", no-user"); | |
| 120 | + return pos; | |
| 121 | +} | |
| 122 | + | |
| 108 | 123 | DeviceState *qdev_device_add(const char *cmdline) |
| 109 | 124 | { |
| 110 | 125 | DeviceInfo *info; |
| ... | ... | @@ -120,8 +135,10 @@ DeviceState *qdev_device_add(const char *cmdline) |
| 120 | 135 | return NULL; |
| 121 | 136 | } |
| 122 | 137 | if (strcmp(driver, "?") == 0) { |
| 138 | + char msg[256]; | |
| 123 | 139 | for (info = device_info_list; info != NULL; info = info->next) { |
| 124 | - fprintf(stderr, "name \"%s\", bus %s\n", info->name, info->bus_info->name); | |
| 140 | + qdev_print_devinfo(info, msg, sizeof(msg)); | |
| 141 | + fprintf(stderr, "%s\n", msg); | |
| 125 | 142 | } |
| 126 | 143 | return NULL; |
| 127 | 144 | } | ... | ... |