From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=38452 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNlBA-0003Hq-ID for qemu-devel@nongnu.org; Wed, 01 Dec 2010 06:48:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PNlB8-00022N-Ne for qemu-devel@nongnu.org; Wed, 01 Dec 2010 06:48:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PNlB8-000227-Gz for qemu-devel@nongnu.org; Wed, 01 Dec 2010 06:48:54 -0500 Date: Wed, 1 Dec 2010 17:18:37 +0530 From: Amit Shah Subject: Re: [Qemu-devel] [PATCH v8 7/7] virtio-console: Enable port throttling when chardev is slow to consume data Message-ID: <20101201114837.GB2962@amit-x200.redhat.com> References: <90e8c0b7db1086c38283f684a159a892b4a66228.1291196789.git.amit.shah@redhat.com> <201012011130.58630.paul@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201012011130.58630.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: Juan Quintela , qemu-devel@nongnu.org, Gerd Hoffmann On (Wed) Dec 01 2010 [11:30:58], Paul Brook wrote: > > /* Callback function that's called when the guest sends us data */ > > static void flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t > > len) { > > VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); > > + int ret; > > > > - 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. Amit