From 88cace9f119b85ac2d40a8b10c24e05ccfa6da07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 9 Dec 2016 00:50:12 +0300 Subject: char: get rid of CharDriver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qemu_chr_new_from_opts() is modified to not need CharDriver backend[] array, but uses instead objectified qmp_query_chardev_backends() and char_get_class(). The alias field is moved outside in a ChardevAlias[], similar to QDevAlias for devices. "kind" and "parse" are moved to ChardevClass ("kind" is to be removed next) Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake --- ui/console.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'ui/console.c') diff --git a/ui/console.c b/ui/console.c index fe03a666f7..84fcbd86fd 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2059,8 +2059,6 @@ static void text_console_do_init(Chardev *chr, DisplayState *ds) qemu_chr_be_generic_open(chr); } -static const CharDriver vc_driver; - static void vc_chr_open(Chardev *chr, ChardevBackend *backend, bool *be_opened, @@ -2189,6 +2187,8 @@ static void char_vc_class_init(ObjectClass *oc, void *data) { ChardevClass *cc = CHARDEV_CLASS(oc); + cc->kind = CHARDEV_BACKEND_KIND_VC; + cc->parse = qemu_chr_parse_vc; cc->open = vc_chr_open; cc->chr_write = vc_chr_write; cc->chr_set_echo = vc_chr_set_echo; @@ -2206,15 +2206,9 @@ void qemu_console_early_init(void) /* set the default vc driver */ if (!object_class_by_name(TYPE_CHARDEV_VC)) { type_register(&char_vc_type_info); - register_char_driver(&vc_driver); } } -static const CharDriver vc_driver = { - .kind = CHARDEV_BACKEND_KIND_VC, - .parse = qemu_chr_parse_vc, -}; - static void register_types(void) { type_register_static(&qemu_console_info); -- cgit v1.2.1 From 0b663b7d77f1a2170fe30a91e3d6de1bb769a378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 9 Dec 2016 11:04:51 +0300 Subject: char: remove class kind field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The class kind is necessary to lookup the chardev name in qmp_chardev_add() after calling qemu_chr_new_from_opts() and to set the appropriate ChardevBackend (mainly to free the right fields). qemu_chr_new_from_opts() can be changed to use a non-qmp function using the chardev class typename. Introduce qemu_chardev_add() to be called from qemu_chr_new_from_opts() and remove the class chardev kind field. Set the backend->type in the parse callback (when non-common fields are added). Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake --- ui/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/console.c') diff --git a/ui/console.c b/ui/console.c index 84fcbd86fd..8c93f2a1e8 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2148,6 +2148,7 @@ void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp) int val; ChardevVC *vc; + backend->type = CHARDEV_BACKEND_KIND_VC; vc = backend->u.vc.data = g_new0(ChardevVC, 1); qemu_chr_parse_common(opts, qapi_ChardevVC_base(vc)); @@ -2187,7 +2188,6 @@ static void char_vc_class_init(ObjectClass *oc, void *data) { ChardevClass *cc = CHARDEV_CLASS(oc); - cc->kind = CHARDEV_BACKEND_KIND_VC; cc->parse = qemu_chr_parse_vc; cc->open = vc_chr_open; cc->chr_write = vc_chr_write; -- cgit v1.2.1