char: move callbacks in CharDriver

This makes the code more declarative, and avoids duplicating the
information on all instances.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Marc-André Lureau 2016-10-21 20:49:37 +03:00 committed by Paolo Bonzini
parent a1698bf183
commit b68e956abe
10 changed files with 381 additions and 260 deletions

View file

@ -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);