|
|
9ae3a8 |
From 4729118339de86313e09cb20414ba699510a80cc Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 6 Nov 2013 14:41:11 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 35/81] qdev-monitor: Group "device_add help" and "info qdm" by category
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1383748882-22831-7-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55532
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 06/17] qdev-monitor: Group "device_add help" and "info qdm" by category
|
|
|
9ae3a8 |
Bugzilla: 1001216
|
|
|
9ae3a8 |
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Output is a long, unsorted list. Not very helpful. Print one list
|
|
|
9ae3a8 |
per device category instead, with a header line identifying the
|
|
|
9ae3a8 |
category, plus a list of uncategorized devices. Print each list in
|
|
|
9ae3a8 |
case-insenitive alphabetical order.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Devices with multiple categories are listed multiple times.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
9ae3a8 |
Message-id: 1381410021-1538-3-git-send-email-armbru@redhat.com
|
|
|
9ae3a8 |
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
|
|
|
9ae3a8 |
(cherry picked from commit a3400aeede46c6c30b6fefb20fc90a43f1f6e7b2)
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qdev-monitor.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++------------
|
|
|
9ae3a8 |
1 file changed, 53 insertions(+), 14 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qdev-monitor.c | 67 ++++++++++++++++++++++++++++++++++++++++++++-----------
|
|
|
9ae3a8 |
1 files changed, 53 insertions(+), 14 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qdev-monitor.c b/qdev-monitor.c
|
|
|
9ae3a8 |
index e54dbc2..aa6a261 100644
|
|
|
9ae3a8 |
--- a/qdev-monitor.c
|
|
|
9ae3a8 |
+++ b/qdev-monitor.c
|
|
|
9ae3a8 |
@@ -75,18 +75,9 @@ static bool qdev_class_has_alias(DeviceClass *dc)
|
|
|
9ae3a8 |
return (qdev_class_get_alias(dc) != NULL);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static void qdev_print_devinfo(ObjectClass *klass, void *opaque)
|
|
|
9ae3a8 |
+static void qdev_print_devinfo(DeviceClass *dc)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- DeviceClass *dc;
|
|
|
9ae3a8 |
- bool *show_no_user = opaque;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- if (!dc || (show_no_user && !*show_no_user && dc->no_user)) {
|
|
|
9ae3a8 |
- return;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- error_printf("name \"%s\"", object_class_get_name(klass));
|
|
|
9ae3a8 |
+ error_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
|
|
|
9ae3a8 |
if (dc->bus_type) {
|
|
|
9ae3a8 |
error_printf(", bus %s", dc->bus_type);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -102,6 +93,55 @@ static void qdev_print_devinfo(ObjectClass *klass, void *opaque)
|
|
|
9ae3a8 |
error_printf("\n");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static gint devinfo_cmp(gconstpointer a, gconstpointer b)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ return strcasecmp(object_class_get_name((ObjectClass *)a),
|
|
|
9ae3a8 |
+ object_class_get_name((ObjectClass *)b));
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+static void qdev_print_devinfos(bool show_no_user)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ static const char *cat_name[DEVICE_CATEGORY_MAX + 1] = {
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_BRIDGE] = "Controller/Bridge/Hub",
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_USB] = "USB",
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_STORAGE] = "Storage",
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_NETWORK] = "Network",
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_INPUT] = "Input",
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_DISPLAY] = "Display",
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_SOUND] = "Sound",
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_MISC] = "Misc",
|
|
|
9ae3a8 |
+ [DEVICE_CATEGORY_MAX] = "Uncategorized",
|
|
|
9ae3a8 |
+ };
|
|
|
9ae3a8 |
+ GSList *list, *elt;
|
|
|
9ae3a8 |
+ int i;
|
|
|
9ae3a8 |
+ bool cat_printed;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ list = g_slist_sort(object_class_get_list(TYPE_DEVICE, false),
|
|
|
9ae3a8 |
+ devinfo_cmp);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ for (i = 0; i <= DEVICE_CATEGORY_MAX; i++) {
|
|
|
9ae3a8 |
+ cat_printed = false;
|
|
|
9ae3a8 |
+ for (elt = list; elt; elt = elt->next) {
|
|
|
9ae3a8 |
+ DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
|
|
|
9ae3a8 |
+ TYPE_DEVICE);
|
|
|
9ae3a8 |
+ if ((i < DEVICE_CATEGORY_MAX
|
|
|
9ae3a8 |
+ ? !test_bit(i, dc->categories)
|
|
|
9ae3a8 |
+ : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX))
|
|
|
9ae3a8 |
+ || (!show_no_user && dc->no_user)) {
|
|
|
9ae3a8 |
+ continue;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (!cat_printed) {
|
|
|
9ae3a8 |
+ error_printf("%s%s devices:\n", i ? "\n" : "",
|
|
|
9ae3a8 |
+ cat_name[i]);
|
|
|
9ae3a8 |
+ cat_printed = true;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ qdev_print_devinfo(dc);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ g_slist_free(list);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static int set_property(const char *name, const char *value, void *opaque)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
DeviceState *dev = opaque;
|
|
|
9ae3a8 |
@@ -147,8 +187,7 @@ int qdev_device_help(QemuOpts *opts)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
driver = qemu_opt_get(opts, "driver");
|
|
|
9ae3a8 |
if (driver && is_help_option(driver)) {
|
|
|
9ae3a8 |
- bool show_no_user = false;
|
|
|
9ae3a8 |
- object_class_foreach(qdev_print_devinfo, TYPE_DEVICE, false, &show_no_user);
|
|
|
9ae3a8 |
+ qdev_print_devinfos(false);
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -587,7 +626,7 @@ void do_info_qtree(Monitor *mon, const QDict *qdict)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void do_info_qdm(Monitor *mon, const QDict *qdict)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- object_class_foreach(qdev_print_devinfo, TYPE_DEVICE, false, NULL);
|
|
|
9ae3a8 |
+ qdev_print_devinfos(true);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|