From 6f974c843c7c3d142f3ce594498431ba2ac19627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 7 Dec 2016 15:13:50 +0300 Subject: gtk: overwrite the console.c char driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of registering a vc handler to allocate the Gtk VC Chardev, overwrite the console.c char driver. A later patch, when switching to QOM, will register a default console vc QOM class if none has been registered before. Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- ui/gtk.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'ui/gtk.c') diff --git a/ui/gtk.c b/ui/gtk.c index 175871a384..04df0ad6af 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1712,16 +1712,14 @@ static void gd_vc_chr_set_echo(Chardev *chr, bool echo) static int nb_vcs; static Chardev *vcs[MAX_VCS]; +static const CharDriver gd_vc_driver; -static Chardev *gd_vc_handler(ChardevVC *vc, Error **errp) +static Chardev *vc_init(const CharDriver *driver, + const char *id, ChardevBackend *backend, + ChardevReturn *ret, bool *be_opened, + Error **errp) { - static const CharDriver gd_vc_driver = { - .instance_size = sizeof(VCChardev), - .kind = CHARDEV_BACKEND_KIND_VC, - .chr_write = gd_vc_chr_write, - .chr_set_echo = gd_vc_chr_set_echo, - }; - + ChardevVC *vc = backend->u.vc.data; ChardevCommon *common = qapi_ChardevVC_base(vc); Chardev *chr; @@ -1737,9 +1735,22 @@ static Chardev *gd_vc_handler(ChardevVC *vc, Error **errp) vcs[nb_vcs++] = chr; + /* console/chardev init sometimes completes elsewhere in a 2nd + * stage, so defer OPENED events until they are fully initialized + */ + *be_opened = false; + return chr; } +static const CharDriver gd_vc_driver = { + .instance_size = sizeof(VCChardev), + .kind = CHARDEV_BACKEND_KIND_VC, + .parse = qemu_chr_parse_vc, .create = vc_init, + .chr_write = gd_vc_chr_write, + .chr_set_echo = gd_vc_chr_set_echo, +}; + static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size, gpointer user_data) { @@ -2336,6 +2347,7 @@ void early_gtk_display_init(int opengl) } #if defined(CONFIG_VTE) - register_vc_handler(gd_vc_handler); + /* overwrite the console.c vc driver */ + register_char_driver(&gd_vc_driver); #endif } -- cgit v1.2.1