aboutsummaryrefslogtreecommitdiff
path: root/chardev
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2021-03-11 17:42:51 +0100
committerKevin Wolf <kwolf@redhat.com>2021-03-19 10:17:14 +0100
commit1254bd3977b30b3af74bb1f6641fe02d0bf5caf8 (patch)
treed12cce0f3524cca299084024a441d4730023a2b2 /chardev
parentddf6dae7e34271332fbc04921d0c91ab6a009b5a (diff)
char: Skip CLI aliases in query-chardev-backends
The aliases "tty" and "parport" are only valid on the command line, QMP commands like chardev-add don't know them. query-chardev-backends should describe QMP and therefore not include them in the list of available backends. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20210311164253.338723-2-kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'chardev')
-rw-r--r--chardev/char.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/chardev/char.c b/chardev/char.c
index 97cafd6849..dd925cf9a4 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -547,7 +547,7 @@ static const struct ChardevAlias {
};
typedef struct ChadevClassFE {
- void (*fn)(const char *name, void *opaque);
+ void (*fn)(const char *name, bool is_cli_alias, void *opaque);
void *opaque;
} ChadevClassFE;
@@ -561,11 +561,13 @@ chardev_class_foreach(ObjectClass *klass, void *opaque)
return;
}
- fe->fn(object_class_get_name(klass) + 8, fe->opaque);
+ fe->fn(object_class_get_name(klass) + 8, false, fe->opaque);
}
static void
-chardev_name_foreach(void (*fn)(const char *name, void *opaque), void *opaque)
+chardev_name_foreach(void (*fn)(const char *name, bool is_cli_alias,
+ void *opaque),
+ void *opaque)
{
ChadevClassFE fe = { .fn = fn, .opaque = opaque };
int i;
@@ -573,12 +575,12 @@ chardev_name_foreach(void (*fn)(const char *name, void *opaque), void *opaque)
object_class_foreach(chardev_class_foreach, TYPE_CHARDEV, false, &fe);
for (i = 0; i < (int)ARRAY_SIZE(chardev_alias_table); i++) {
- fn(chardev_alias_table[i].alias, opaque);
+ fn(chardev_alias_table[i].alias, true, opaque);
}
}
static void
-help_string_append(const char *name, void *opaque)
+help_string_append(const char *name, bool is_cli_alias, void *opaque)
{
GString *str = opaque;
@@ -798,11 +800,16 @@ ChardevInfoList *qmp_query_chardev(Error **errp)
}
static void
-qmp_prepend_backend(const char *name, void *opaque)
+qmp_prepend_backend(const char *name, bool is_cli_alias, void *opaque)
{
ChardevBackendInfoList **list = opaque;
- ChardevBackendInfo *value = g_new0(ChardevBackendInfo, 1);
+ ChardevBackendInfo *value;
+ if (is_cli_alias) {
+ return;
+ }
+
+ value = g_new0(ChardevBackendInfo, 1);
value->name = g_strdup(name);
QAPI_LIST_PREPEND(*list, value);
}