From b68e956abe2ad0a1ecf53868e0bf1a61b418ded8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 21 Oct 2016 20:49:37 +0300 Subject: char: move callbacks in CharDriver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the code more declarative, and avoids duplicating the information on all instances. Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- ui/gtk.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ui/gtk.c') diff --git a/ui/gtk.c b/ui/gtk.c index 86368e38b7..608400b56d 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1703,6 +1703,12 @@ static CharDriverState *vcs[MAX_VCS]; static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp) { + static const CharDriver gd_vc_driver = { + .kind = CHARDEV_BACKEND_KIND_VC, + .chr_write = gd_vc_chr_write, + .chr_set_echo = gd_vc_chr_set_echo, + }; + ChardevCommon *common = qapi_ChardevVC_base(vc); CharDriverState *chr; @@ -1711,14 +1717,11 @@ static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp) return NULL; } - chr = qemu_chr_alloc(common, errp); + chr = qemu_chr_alloc(&gd_vc_driver, common, errp); if (!chr) { return NULL; } - chr->chr_write = gd_vc_chr_write; - chr->chr_set_echo = gd_vc_chr_set_echo; - /* Temporary, until gd_vc_vte_init runs. */ chr->opaque = g_new0(VirtualConsole, 1); -- cgit v1.2.1