All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for 6.1] ui/gtk: retry sending VTE console input
@ 2021-08-10  6:32 Volker Rümelin
  2021-08-10  8:16 ` Marc-André Lureau
  2021-08-10  8:55 ` Gerd Hoffmann
  0 siblings, 2 replies; 3+ messages in thread
From: Volker Rümelin @ 2021-08-10  6:32 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Marc-André Lureau, qemu-devel

Commit 584af1f1d9 ("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: 584af1f1d9 ("ui/gtk: add a keyboard fifo to the VTE consoles")
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 ui/gtk.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 974e4dfc0b..cfb0728d1f 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1646,16 +1646,14 @@ static void gd_vc_send_chars(VirtualConsole *vc)
 
     len = qemu_chr_be_can_write(vc->vte.chr);
     avail = fifo8_num_used(&vc->vte.out_fifo);
-    if (len > avail) {
-        len = avail;
-    }
-    while (len > 0) {
+    while (len > 0 && avail > 0) {
         const uint8_t *buf;
         uint32_t size;
 
-        buf = fifo8_pop_buf(&vc->vte.out_fifo, len, &size);
+        buf = fifo8_pop_buf(&vc->vte.out_fifo, MIN(len, avail), &size);
         qemu_chr_be_write(vc->vte.chr, (uint8_t *)buf, size);
-        len -= size;
+        len = qemu_chr_be_can_write(vc->vte.chr);
+        avail -= size;
     }
 }
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for 6.1] ui/gtk: retry sending VTE console input
  2021-08-10  6:32 [PATCH for 6.1] ui/gtk: retry sending VTE console input Volker Rümelin
@ 2021-08-10  8:16 ` Marc-André Lureau
  2021-08-10  8:55 ` Gerd Hoffmann
  1 sibling, 0 replies; 3+ messages in thread
From: Marc-André Lureau @ 2021-08-10  8:16 UTC (permalink / raw)
  To: Volker Rümelin; +Cc: Gerd Hoffmann, QEMU

[-- Attachment #1: Type: text/plain, Size: 1713 bytes --]

On Tue, Aug 10, 2021 at 10:35 AM Volker Rümelin <vr_qemu@t-online.de> wrote:

> Commit 584af1f1d9 ("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: 584af1f1d9 ("ui/gtk: add a keyboard fifo to the VTE consoles")
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

---
>  ui/gtk.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/ui/gtk.c b/ui/gtk.c
> index 974e4dfc0b..cfb0728d1f 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -1646,16 +1646,14 @@ static void gd_vc_send_chars(VirtualConsole *vc)
>
>      len = qemu_chr_be_can_write(vc->vte.chr);
>      avail = fifo8_num_used(&vc->vte.out_fifo);
> -    if (len > avail) {
> -        len = avail;
> -    }
> -    while (len > 0) {
> +    while (len > 0 && avail > 0) {
>          const uint8_t *buf;
>          uint32_t size;
>
> -        buf = fifo8_pop_buf(&vc->vte.out_fifo, len, &size);
> +        buf = fifo8_pop_buf(&vc->vte.out_fifo, MIN(len, avail), &size);
>          qemu_chr_be_write(vc->vte.chr, (uint8_t *)buf, size);
> -        len -= size;
> +        len = qemu_chr_be_can_write(vc->vte.chr);
> +        avail -= size;
>      }
>  }
>
> --
> 2.26.2
>
>

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 2601 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for 6.1] ui/gtk: retry sending VTE console input
  2021-08-10  6:32 [PATCH for 6.1] ui/gtk: retry sending VTE console input Volker Rümelin
  2021-08-10  8:16 ` Marc-André Lureau
@ 2021-08-10  8:55 ` Gerd Hoffmann
  1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2021-08-10  8:55 UTC (permalink / raw)
  To: Volker Rümelin; +Cc: Marc-André Lureau, qemu-devel

On Tue, Aug 10, 2021 at 08:32:57AM +0200, Volker Rümelin wrote:
> Commit 584af1f1d9 ("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: 584af1f1d9 ("ui/gtk: add a keyboard fifo to the VTE consoles")
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>

Queued.

thanks,
  Gerd



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-10  8:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10  6:32 [PATCH for 6.1] ui/gtk: retry sending VTE console input Volker Rümelin
2021-08-10  8:16 ` Marc-André Lureau
2021-08-10  8:55 ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.