[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/6] char: Factor out qemu_chr_print_types()
From: |
Kevin Wolf |
Subject: |
[PATCH v2 2/6] char: Factor out qemu_chr_print_types() |
Date: |
Fri, 23 Oct 2020 18:13:08 +0200 |
We'll want to call the same from a non-QemuOpts code path.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
include/chardev/char.h | 1 +
chardev/char.c | 16 ++++++++++------
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/include/chardev/char.h b/include/chardev/char.h
index db42f0a8c6..3b91645081 100644
--- a/include/chardev/char.h
+++ b/include/chardev/char.h
@@ -212,6 +212,7 @@ void qemu_chr_be_update_read_handlers(Chardev *s,
*/
void qemu_chr_be_event(Chardev *s, QEMUChrEvent event);
+void qemu_chr_print_types(void);
int qemu_chr_add_client(Chardev *s, int fd);
Chardev *qemu_chr_find(const char *name);
diff --git a/chardev/char.c b/chardev/char.c
index 78553125d3..4d188bfa6f 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -633,6 +633,15 @@ ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Error
**errp)
return backend;
}
+void qemu_chr_print_types(void)
+{
+ g_autoptr(GString) str = g_string_new("");
+
+ chardev_name_foreach(help_string_append, str);
+
+ qemu_printf("Available chardev backend types: %s\n", str->str);
+}
+
Chardev *qemu_chr_new_from_opts(QemuOpts *opts, GMainContext *context,
Error **errp)
{
@@ -644,12 +653,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts,
GMainContext *context,
char *bid = NULL;
if (name && is_help_option(name)) {
- GString *str = g_string_new("");
-
- chardev_name_foreach(help_string_append, str);
-
- qemu_printf("Available chardev backend types: %s\n", str->str);
- g_string_free(str, true);
+ qemu_chr_print_types();
return NULL;
}
--
2.28.0
- [PATCH v2 0/6] qemu-storage-daemon: QAPIfy --chardev, Kevin Wolf, 2020/10/23
- [PATCH v2 2/6] char: Factor out qemu_chr_print_types(),
Kevin Wolf <=
- [PATCH v2 1/6] char/stdio: Fix QMP default for 'signal', Kevin Wolf, 2020/10/23
- [PATCH v2 4/6] qapi: Optionally parse simple unions as flat, Kevin Wolf, 2020/10/23
- [PATCH v2 5/6] tests/qapi-schema: Flat representation of simple unions, Kevin Wolf, 2020/10/23
- [PATCH v2 6/6] qemu-storage-daemon: Use qmp_chardev_add() for --chardev, Kevin Wolf, 2020/10/23
- [PATCH v2 3/6] qapi: Remove wrapper struct for simple unions, Kevin Wolf, 2020/10/23