mirror of
https://github.com/qemu/qemu.git
synced 2025-08-08 08:05:17 +00:00
char: start converting mux driver to use CharBackend
Start using qemu_chr_fe* CharBackend functions: initialize a CharBackend and use qemu_chr_fe_set_handlers(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-11-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
94a40fc560
commit
ecb672d14f
12
qemu-char.c
12
qemu-char.c
@ -502,10 +502,8 @@ void qemu_chr_add_handlers_full(CharDriverState *s,
|
|||||||
|
|
||||||
if (s->is_mux) {
|
if (s->is_mux) {
|
||||||
tag = mux_chr_new_handler_tag(s, &error_abort);
|
tag = mux_chr_new_handler_tag(s, &error_abort);
|
||||||
if (tag == 0) {
|
|
||||||
mux_chr_set_handlers(s, context);
|
mux_chr_set_handlers(s, context);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
qemu_chr_set_handlers(s, fd_can_read, fd_read,
|
qemu_chr_set_handlers(s, fd_can_read, fd_read,
|
||||||
fd_event, opaque, context, tag);
|
fd_event, opaque, context, tag);
|
||||||
@ -557,6 +555,7 @@ struct MuxDriver {
|
|||||||
IOEventHandler *chr_event[MAX_MUX];
|
IOEventHandler *chr_event[MAX_MUX];
|
||||||
void *ext_opaque[MAX_MUX];
|
void *ext_opaque[MAX_MUX];
|
||||||
CharDriverState *drv;
|
CharDriverState *drv;
|
||||||
|
CharBackend chr;
|
||||||
int focus;
|
int focus;
|
||||||
int mux_cnt;
|
int mux_cnt;
|
||||||
int term_got_escape;
|
int term_got_escape;
|
||||||
@ -847,7 +846,7 @@ static void mux_chr_set_handlers(CharDriverState *chr, GMainContext *context)
|
|||||||
MuxDriver *d = chr->opaque;
|
MuxDriver *d = chr->opaque;
|
||||||
|
|
||||||
/* Fix up the real driver with mux routines */
|
/* Fix up the real driver with mux routines */
|
||||||
qemu_chr_add_handlers_full(d->drv,
|
qemu_chr_fe_set_handlers(&d->chr,
|
||||||
mux_chr_can_read,
|
mux_chr_can_read,
|
||||||
mux_chr_read,
|
mux_chr_read,
|
||||||
mux_chr_event,
|
mux_chr_event,
|
||||||
@ -906,6 +905,10 @@ static CharDriverState *qemu_chr_open_mux(const char *id,
|
|||||||
*/
|
*/
|
||||||
chr->explicit_be_open = muxes_realized ? 0 : 1;
|
chr->explicit_be_open = muxes_realized ? 0 : 1;
|
||||||
chr->is_mux = 1;
|
chr->is_mux = 1;
|
||||||
|
if (!qemu_chr_fe_init(&d->chr, d->drv, errp)) {
|
||||||
|
qemu_chr_free(chr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return chr;
|
return chr;
|
||||||
}
|
}
|
||||||
@ -4231,9 +4234,6 @@ void qemu_chr_disconnect(CharDriverState *chr)
|
|||||||
|
|
||||||
static void qemu_chr_free_common(CharDriverState *chr)
|
static void qemu_chr_free_common(CharDriverState *chr)
|
||||||
{
|
{
|
||||||
if (chr->be) {
|
|
||||||
chr->be->chr = NULL;
|
|
||||||
}
|
|
||||||
g_free(chr->filename);
|
g_free(chr->filename);
|
||||||
g_free(chr->label);
|
g_free(chr->label);
|
||||||
if (chr->logfd != -1) {
|
if (chr->logfd != -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user