qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 00/12][RFC] char: add flow control and fix	guest_[open|close]
Date: Thu, 4 Aug 2011 20:16:38 +0530	[thread overview]
Message-ID: <20110804144638.GA25069@amit-x200.redhat.com> (raw)
In-Reply-To: <4E3A9A7B.6040205@us.ibm.com>

(Adding Gerd to cc)

On (Thu) 04 Aug 2011 [08:11:23], Anthony Liguori wrote:
> On 08/04/2011 01:45 AM, Amit Shah wrote:
> >On (Mon) 01 Aug 2011 [09:22:58], Anthony Liguori wrote:
> >>The char layer has been growing some nasty warts for some time now as we ask it
> >>to do things it was never intended on doing.  It's been long over due for an
> >>overhaul and its become evident to me that we need to address this first before
> >>adding any more features to the char layer.
> >>
> >>This series is the start at sanitizing the char layer.  It effectively turns
> >>the char layer into an internal pipe.  It supports flow control using an
> >>intermediate ring queue for each direction.
> >
> >Let's break down what we have now:
> >
> >* chardev ->  guest (backend writes):
> >    we have connect/disconnect notifications, we have an ugly
> >    can_read() implementation that is executed each time iohandlers are
> >    run.  However, it gives us reasonable flow control.
> 
> It has one major flaw.  It assumes that the backends can implement
> polling to determine when the front end can read.
> 
> This makes it impossible to implement a backend that isn't
> associated with a file descriptor (like a QMP server as required by
> the guest agent).

OK; is a ring the best way to get these 'into the fold'?  How about a
separate, qemu-specific poll() for such code?  Does glib have any
support for this?  Should we look at extending glib with such library
code instead?

> >* guest ->  chardev (frontend writes):
> >    we don't get chardev connect/disconnect events, neither do we get
> >    to know if the chardev is overwhelmed with data and to stop sending
> >    any more till it has some room in its queue.
> 
> We do have connect/disconnect event--that's open/close.

chardev connect/disconnect events right now aren't useful.  Eg., a tcp
disconnect or a unix disconnect is only noticed when the socket gets
re-connected.  And this is because select() can't give us POLLHUP.

> >    This is because we
> >    need poll semantics instead of select to get POLLIN and POLLOUT
> >    events, using which we can ascertain what state the chardev is in.
> >    There's no call corresponding to the existing qemu_chr_can_read(),
> >    which essentially confirms if a chardev is able to handle data for
> >    output.  This series only adds a qemu_char_fe_can_write(), doesn't
> >    add callbacks for connect/disconnect events since that depends on
> >    polling.
> 
> There are already events for connect/disconnect so I'm not sure what
> you're talking about.

(see above)

> >The problem I think with adding a buffer is it just solves the flow
> >control problem without solving the connect/disconnect events issue by
> >just switching to poll,
> 
> I don't understand at all what you're saying here :-)
> 
> Hopefully you'd agree, that from a design perspective, the closer a
> chrdrv looks to a normal unix socket, the more correct it is.

What I wanted to say there, without knowing about the special in-qemu
QMP server usage, is: we already have an fd for host-side chardevs, so
introducing a ring isn't beneficial.

For the frontend (as well as to take care of the QMP server case you
cite), we can have something like a QEMUFD, that supports open, read,
write, close and poll() semantics.  Getting edge notifications from
frontends shouldn't really be a problem, and all of this can be tied
into the main loop.

Is that workable?  Removes the need for a ring for sure.

> After this series, we have:
> 
> 1) read/write methods that behave like unix read/write (except zero
> indicates EAGAIN, not EOF).
> 
> 2) OPENED/CLOSE events that map to accept/EOF
> 
> 3) edge events for readability that semantically map to epoll()
> 
> I think that's pretty complete.  I don't see anything that's missing.

(keeping for context)

		Amit

      reply	other threads:[~2011-08-04 14:46 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01 14:22 [Qemu-devel] [PATCH 00/12][RFC] char: add flow control and fix guest_[open|close] Anthony Liguori
2011-08-01 14:22 ` [Qemu-devel] [PATCH 01/12] char: rename qemu_chr_write() to qemu_chr_fe_write() Anthony Liguori
2011-08-04 16:00   ` Avi Kivity
2011-08-04 16:11     ` Anthony Liguori
2011-08-04 16:14       ` Avi Kivity
2011-08-04 16:17         ` Avi Kivity
2011-08-04 16:22           ` Anthony Liguori
2011-08-04 16:21         ` Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 02/12] char: rename qemu_chr_[can_]read() to qemu_chr_be_[can_]write() Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 03/12] char: introduce tx queue to enable Unix style flow control Anthony Liguori
2011-08-04 16:04   ` Avi Kivity
2011-08-04 16:31     ` Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 04/12] char: introduce backend tx queue Anthony Liguori
2011-08-01 15:33   ` Stefan Hajnoczi
2011-08-01 15:37     ` Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 05/12] char: add read functions for backend and frontend Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 06/12] char: add an edge event API for the front ends Anthony Liguori
2011-08-01 15:39   ` Stefan Hajnoczi
2011-08-01 15:40     ` Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 07/12] char: add backend edge notification interface Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 08/12] char: make monitor use new style interface Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 09/12] char: rename qemu_chr_guest_open() -> qemu_chr_fe_open() Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 10/12] char: rename qemu_chr_guest_close() -> qemu_chr_fe_close() Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 11/12] char: make all devices do qemu_chr_fe_open() Anthony Liguori
2011-08-01 14:23 ` [Qemu-devel] [PATCH 12/12] char: enforce the use of qemu_chr_guest_open() Anthony Liguori
2011-08-01 15:38   ` Alon Levy
2011-08-01 15:39     ` Anthony Liguori
2011-08-01 16:04 ` [Qemu-devel] [PATCH 00/12][RFC] char: add flow control and fix guest_[open|close] Alon Levy
2011-08-01 16:13   ` Anthony Liguori
2011-08-01 17:42 ` Hans de Goede
2011-08-01 21:54 ` Blue Swirl
2011-08-01 22:47   ` Anthony Liguori
2011-08-04  6:45 ` Amit Shah
2011-08-04 13:11   ` Anthony Liguori
2011-08-04 14:46     ` Amit Shah [this message]

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=20110804144638.GA25069@amit-x200.redhat.com \
    --to=amit.shah@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=hdegoede@redhat.com \
    --cc=kraxel@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).