Skip to content

Commit

Permalink
char: fix ctrl-a b not working
Browse files Browse the repository at this point in the history
CharDriverState.be should be updated to point to the current
associated backend.

Fix the regression introduced in the "mux" chardev from commit
a4afa54.

https://bugs.launchpad.net/bugs/1654137

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170110110621.15287-1-marcandre.lureau@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
elmarco authored and bonzini committed Jan 16, 2017
1 parent 5ad4a2b commit fb5e19d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions qemu-char.c
Expand Up @@ -499,7 +499,7 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)

static void remove_fd_in_watch(CharDriverState *chr);
static void mux_chr_set_handlers(CharDriverState *chr, GMainContext *context);
static void mux_set_focus(MuxDriver *d, int focus);
static void mux_set_focus(CharDriverState *chr, int focus);

static int null_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
{
Expand Down Expand Up @@ -666,7 +666,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
case 'c':
assert(d->mux_cnt > 0); /* handler registered with first fe */
/* Switch to the next registered device */
mux_set_focus(d, (d->focus + 1) % d->mux_cnt);
mux_set_focus(chr, (d->focus + 1) % d->mux_cnt);
break;
case 't':
d->timestamps = !d->timestamps;
Expand Down Expand Up @@ -826,8 +826,10 @@ static void mux_chr_set_handlers(CharDriverState *chr, GMainContext *context)
context, true);
}

static void mux_set_focus(MuxDriver *d, int focus)
static void mux_set_focus(CharDriverState *chr, int focus)
{
MuxDriver *d = chr->opaque;

assert(focus >= 0);
assert(focus < d->mux_cnt);

Expand All @@ -836,6 +838,7 @@ static void mux_set_focus(MuxDriver *d, int focus)
}

d->focus = focus;
chr->be = d->backends[focus];
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN);
}

Expand Down Expand Up @@ -935,7 +938,9 @@ void qemu_chr_fe_deinit(CharBackend *b)

if (b->chr) {
qemu_chr_fe_set_handlers(b, NULL, NULL, NULL, NULL, NULL, true);
b->chr->be = NULL;
if (b->chr->be == b) {
b->chr->be = NULL;
}
if (b->chr->is_mux) {
MuxDriver *d = b->chr->opaque;
d->backends[b->tag] = NULL;
Expand Down Expand Up @@ -999,7 +1004,7 @@ void qemu_chr_fe_take_focus(CharBackend *b)
}

if (b->chr->is_mux) {
mux_set_focus(b->chr->opaque, b->tag);
mux_set_focus(b->chr, b->tag);
}
}

Expand Down

0 comments on commit fb5e19d

Please sign in to comment.