From: David Woodhouse <dwmw2@infradead.org>
To: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Cc: Paul Brook <paul@codesourcery.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] Always use nonblocking mode for qemu_chr_open_fd.
Date: Wed, 01 Feb 2017 12:33:09 +0000 [thread overview]
Message-ID: <1485952389.30423.114.camel@infradead.org> (raw)
In-Reply-To: <488DB976.4030203@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2447 bytes --]
(very old thread)
On Mon, 2008-07-28 at 14:20 +0200, Gerd Hoffmann wrote:
> Jamie Lokier wrote:
> > Is the problem that you want qemu to block when they do that?
> I want ptys behave as close as possible to tcp/unix sockets:
>
> * when nobody is connected, then don't send data. Because we will
> block forever once the kernel buffer is full, which is bad.
> * when someone is connected, we want him get all data. If the reader
> is too slow to keep up, that means we will block now and then, yes.
> Sockets do that too.
Hm? Sockets operate in O_NONBLOCK mode, don't they?
If the other end stops consuming data and the kernel buffers fill up,
the serial driver ignores the resulting -EAGAIN and drops the byte.
And although it's "lossy", it's sane behaviour. It's exactly what you
get on a real RS232 serial line too; if the other end doesn't keep up
with reading the data out of its end, *it* is going to miss bytes.
That's always been the case, and I don't think we need to worry about
it.
We *certainly* shouldn't be blocking the whole guest CPU in the outb
instruction, waiting for ever for the other end to consume data. Which
is what we seem to do at the moment for PTYs.
> Additionally we can also try to drive the ptys / sockets / whatever
> filehandles in non-blocking mode and try propagating the state back to
> the guest so it stops writing. That is a different issue, although
> related. IIRC the xen guys have some bits for that ...
We *could*, I suppose, although as noted I'm not sure it's necessary. A
relatively easy answer might be for the serial driver to spot the
-EAGAIN and keep the byte in the transmit FIFO/register, and refrain
from reasserting THRE/TEMT until it's actually managed to send the
byte.
If we really wanted to support fully lossless serial communication, a
better option might be to implement the hardware flow control lines,
and assert CTS only when the (pty/socket/etc.) file descriptor is
writable. Then *if* the guest chooses to use hardware flow control,
that ought to work.
But I still don't think it's necessary. Can't we just make the PTY file
descriptor non-blocking, and then perhaps the monitoring logic added in
commit 279e694bc ("Attempt to detect unconnected ptys (Gerd Hoffman)")
can get simpler because it only has to poll an active device for
connectivity in the case where the write() fails.
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 4938 bytes --]
next prev parent reply other threads:[~2017-02-01 12:35 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-18 13:24 [Qemu-devel] [PATCH 2/3] Always use nonblocking mode for qemu_chr_open_fd Ian Jackson
2008-07-23 1:26 ` Anthony Liguori
2008-07-23 8:24 ` Daniel P. Berrange
2008-07-23 11:48 ` Gerd Hoffmann
2008-07-23 12:15 ` Daniel P. Berrange
2008-07-23 12:52 ` Gerd Hoffmann
2008-07-23 12:59 ` Daniel P. Berrange
2008-07-23 14:24 ` Gerd Hoffmann
2008-07-23 15:24 ` Anthony Liguori
2008-07-23 15:31 ` Daniel P. Berrange
2008-07-23 15:32 ` Anthony Liguori
2008-07-23 16:17 ` Gerd Hoffmann
2008-07-23 16:33 ` Anthony Liguori
2008-07-23 19:08 ` Jamie Lokier
2008-07-24 7:24 ` Gerd Hoffmann
2008-07-24 7:54 ` Gerd Hoffmann
2008-07-24 8:31 ` Daniel P. Berrange
2008-07-24 9:24 ` Jamie Lokier
2008-07-24 9:33 ` Samuel Thibault
2008-07-24 11:18 ` Gerd Hoffmann
2008-07-23 16:11 ` Gerd Hoffmann
2008-07-23 16:31 ` Anthony Liguori
2008-07-24 8:35 ` Daniel P. Berrange
2008-07-24 14:23 ` Anthony Liguori
2008-07-24 15:07 ` Jamie Lokier
2008-07-24 14:53 ` Gerd Hoffmann
2008-07-23 16:44 ` Paul Brook
2008-07-24 17:37 ` Anthony Liguori
2008-07-25 7:15 ` Gerd Hoffmann
2008-07-25 16:17 ` Jamie Lokier
2008-07-28 8:49 ` Gerd Hoffmann
2008-07-28 11:59 ` Jamie Lokier
2008-07-28 12:20 ` Gerd Hoffmann
2017-02-01 12:33 ` David Woodhouse [this message]
2008-07-24 15:37 ` [Qemu-devel] " Anthony Liguori
2008-07-25 11:42 ` Gerd Hoffmann
2008-07-25 15:04 ` Anthony Liguori
2008-07-28 9:59 ` Gerd Hoffmann
2008-07-28 18:55 ` Anthony Liguori
2008-07-23 9:34 ` [Qemu-devel] " Kevin Wolf
2008-07-23 10:17 ` Ian Jackson
2008-07-23 11:43 ` Kevin Wolf
2008-07-23 12:04 ` Gerd Hoffmann
2008-07-23 12:18 ` Paul Brook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485952389.30423.114.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=kraxel@redhat.com \
--cc=paul@codesourcery.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).