From: Gerd Hoffmann <kraxel@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] Always use nonblocking mode for qemu_chr_open_fd.
Date: Wed, 23 Jul 2008 14:52:09 +0200 [thread overview]
Message-ID: <48872979.4050107@redhat.com> (raw)
In-Reply-To: <20080723121510.GJ2291@redhat.com>
Daniel P. Berrange wrote:
> On Wed, Jul 23, 2008 at 01:48:14PM +0200, Gerd Hoffmann wrote:
>> Daniel P. Berrange wrote:
>>
>>> In the case of the PTY backend, the only time I'd expect data to be dropped
>>> is if there was no active slave open. If an application has the PTY open
>>> and is interacting, then I'd want to get all data.
>> Yep, that would be most useful (and also matches what is done for tcp
>> for example). Now the interesting question is: How can qemu figure (in
>> a portable way) whenever there is some process listening on the slave side?
>
> Well you get SIGHUP when the slave side closes, but the problem is then
> detecting the re-connect.
I don't see a SIGHUP.
Played around a bit with it (on linux) and found:
The write() syscall doesn't show different behavior. It just queues up
data and either blocks or returns -EAGAIN when the buffer is full. No
matter whenever someone is connected or not.
The read() syscall blocks or returns -EAGAIN when connected. It returns
-EIO when unconnected (and flagged ready by select/poll). So we can
detect disconnects that way.
> If you keep polling on the master PTY you'll just
> spin getting SIGHUP all the time.
Yep. Well, I've seen it spinning getting -EIO, but thats pretty much
the same issue.
> On Linux you can deal with this by using
> epoll() in edge-triggered mode instead of poll which is level-triggered.
> Unfortunately epoll is Linux specific, so you'd need to have alternate
> impls of the guts of the QEMU event loop for every OS :-(
It is probably easier take the fd out of the polling loop and check now
and then using a timer. Not perfect, but IMHO better that maintaining
three different poll implementations.
Which means we need our own code for ptys and can't use the generic fd
functions. I'll go trying cooking up a patch ...
cheers,
Gerd
--
http://kraxel.fedorapeople.org/xenner/
next prev parent reply other threads:[~2008-07-23 12:52 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 [this message]
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
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=48872979.4050107@redhat.com \
--to=kraxel@redhat.com \
--cc=berrange@redhat.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).