qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Brook <paul@codesourcery.com>
To: Amit Shah <amit.shah@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>,
	qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data
Date: Wed, 1 Dec 2010 13:08:26 +0000	[thread overview]
Message-ID: <201012011308.26315.paul@codesourcery.com> (raw)
In-Reply-To: <20101201121256.GD2962@amit-x200.redhat.com>

> On (Wed) Dec 01 2010 [11:59:35], Paul Brook wrote:
> > > > > -    qemu_chr_write(vcon->chr, buf, len);
> > > > > +    ret = qemu_chr_write(vcon->chr, buf, len);
> > > > > +    if (ret == -EAGAIN) {
> > > > > +        virtio_serial_throttle_port(port, true);
> > > > > +    }
> > > > > 
> > > > >  }
> > > > 
> > > > This looks wrong. It will loose data in the case of a partial write
> > > > (i.e. ret < len)
> > > 
> > > That doesn't happen currently (qemu_chr_write doesn't return a value >
> > > 0 but < len).
> > > 
> > > I had code in there to handle it, but that would change behaviour for
> > > current users of qemu_chr_write(), which is a risk.
> > 
> > Doesn't that make the code almost completely pointless?
> 
> Not really -- I did have code for partial writes, but removed it before
> this submission (had it in previous versions).
> 
> The (new) do_send loop:
> 
>     len = len1;
>     while (len > 0) {
>         ret = write(fd, buf, len);
>         if (ret < 0) {
>             if (errno == EAGAIN && nonblock) {
>                 return -EAGAIN;
>             }
>             if (errno != EINTR && errno != EAGAIN) {
>                 return -1;
>             }
>         } else if (ret == 0) {
>             break;
>         } else {
>             buf += ret;
>             len -= ret;
>         }
>     }
> 
> when there's a partial write, it tries to do a write again, which will
> fail with -EAGAIN.

Doesn't that cause the first partial chunk to be incorrectly transmitted 
twice? You may only return EAGAIN if no data was transmitted.

Paul

  reply	other threads:[~2010-12-01 13:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-01  9:54 [Qemu-devel] [PATCH v8 0/7] char: non-blocking writes, virtio-console flow control Amit Shah
2010-12-01  9:54 ` [Qemu-devel] [PATCH v8 1/7] virtio-console: Factor out common init between console and generic ports Amit Shah
2010-12-01  9:54 ` [Qemu-devel] [PATCH v8 2/7] char: Add a QemuChrHandlers struct to initialise chardev handlers Amit Shah
2010-12-01  9:54 ` [Qemu-devel] [PATCH v8 3/7] char: Introduce char_set/remove_fd_handlers() Amit Shah
2010-12-01  9:54 ` [Qemu-devel] [PATCH v8 4/7] char: Add framework for a 'write unblocked' callback Amit Shah
2010-12-01  9:54 ` [Qemu-devel] [PATCH v8 5/7] char: Update send_all() to handle nonblocking chardev write requests Amit Shah
2010-12-01  9:54 ` [Qemu-devel] [PATCH v8 6/7] char: Equip the unix/tcp backend to handle nonblocking writes Amit Shah
2010-12-01  9:54 ` [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data Amit Shah
2010-12-01 11:30   ` Paul Brook
2010-12-01 11:48     ` Amit Shah
2010-12-01 11:59       ` Paul Brook
2010-12-01 12:12         ` Amit Shah
2010-12-01 13:08           ` Paul Brook [this message]
2010-12-02  9:21             ` Amit Shah
2010-12-02 17:31               ` Paul Brook
2010-12-06  6:55                 ` Amit Shah
2010-12-06  9:35                   ` Paul Brook
2010-12-06 10:11                     ` Amit Shah
2010-12-06 13:23                       ` Paul Brook
2010-12-07  7:11                         ` Amit Shah
2010-12-08 12:56                           ` Paul Brook
2010-12-08 14:25                             ` Amit Shah
2010-12-08 16:54                               ` 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=201012011308.26315.paul@codesourcery.com \
    --to=paul@codesourcery.com \
    --cc=amit.shah@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).