qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] ui/gtk.c does not check qemu_chr_be_can_write()
@ 2014-09-29 13:15 Michael Walle
  2014-09-30  8:45 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Walle @ 2014-09-29 13:15 UTC (permalink / raw)
  To: Anthony Liguori, Gerd Hoffmann; +Cc: qemu-devel

Hi Anthony, Hi Gerd,

the GTK frontend does not respect the the "chr_can_read" hook. The 
frontend just writes characters to the device using qemu_chr_be_write() 
without checking if the device can receive any input 
(qemu_chr_be_can_write()).

At least for my device model (hw/char/milkymist-uart.c), this results in 
an assertion because the rx callback asserts if there is already a 
character in the buffer. It assumes that the uart_rx callback is only 
called, if the uart_can_rx callback returns a value >0.

Do I make a wrong assumption here?

-michael

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

* Re: [Qemu-devel] ui/gtk.c does not check qemu_chr_be_can_write()
  2014-09-29 13:15 [Qemu-devel] ui/gtk.c does not check qemu_chr_be_can_write() Michael Walle
@ 2014-09-30  8:45 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2014-09-30  8:45 UTC (permalink / raw)
  To: Michael Walle; +Cc: qemu-devel, Anthony Liguori

On Mo, 2014-09-29 at 15:15 +0200, Michael Walle wrote:
> Hi Anthony, Hi Gerd,
> 
> the GTK frontend does not respect the the "chr_can_read" hook. The 
> frontend just writes characters to the device using qemu_chr_be_write() 
> without checking if the device can receive any input 
> (qemu_chr_be_can_write()).
> 
> At least for my device model (hw/char/milkymist-uart.c), this results in 
> an assertion because the rx callback asserts if there is already a 
> character in the buffer. It assumes that the uart_rx callback is only 
> called, if the uart_can_rx callback returns a value >0.
> 
> Do I make a wrong assumption here?

The assumption is correct, gtk should be fixed to not do that.

I'm not sure how to do that best though.  Most other chardevs just pass
on the qemu_chr_be_can_write return value in the poll handler (see
fd_chr_read_poll for example).  gtk gets the data from a vte widget
callback though, not a file handle which where we can decide to just not
read from unless we can actually forward the data to the backend ...

Guess we have to buffer the data and kick a timer in case our buffer is
not empty to flush it.

Better ideas anyone?

cheers,
  Gerd

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

end of thread, other threads:[~2014-09-30  8:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-29 13:15 [Qemu-devel] ui/gtk.c does not check qemu_chr_be_can_write() Michael Walle
2014-09-30  8:45 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).