Skip to content

Commit 7bce330

Browse files
Volker Rümelinkraxel
authored andcommitted
ui/gtk: retry sending VTE console input
Commit 584af1f ("ui/gtk: add a keyboard fifo to the VTE consoles") changed the VTE chardev backend code to rely on the chr_accept_input() callback function. The code expects a chr_accept_input() call whenever qemu_chr_be_can_write() bytes were written. It turns out this is wrong. Some chardev frontends only call this callback after can_write was 0. Change the code to send data until the keyboard fifo is empty or qemu_chr_be_can_write() returns 0. Fixes: 584af1f ("ui/gtk: add a keyboard fifo to the VTE consoles") Signed-off-by: Volker Rümelin <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent bccabb3 commit 7bce330

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ui/gtk.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,16 +1646,14 @@ static void gd_vc_send_chars(VirtualConsole *vc)
16461646

16471647
len = qemu_chr_be_can_write(vc->vte.chr);
16481648
avail = fifo8_num_used(&vc->vte.out_fifo);
1649-
if (len > avail) {
1650-
len = avail;
1651-
}
1652-
while (len > 0) {
1649+
while (len > 0 && avail > 0) {
16531650
const uint8_t *buf;
16541651
uint32_t size;
16551652

1656-
buf = fifo8_pop_buf(&vc->vte.out_fifo, len, &size);
1653+
buf = fifo8_pop_buf(&vc->vte.out_fifo, MIN(len, avail), &size);
16571654
qemu_chr_be_write(vc->vte.chr, (uint8_t *)buf, size);
1658-
len -= size;
1655+
len = qemu_chr_be_can_write(vc->vte.chr);
1656+
avail -= size;
16591657
}
16601658
}
16611659

0 commit comments

Comments
 (0)