From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40819 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNku3-0006fA-4w for qemu-devel@nongnu.org; Wed, 01 Dec 2010 06:31:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PNktq-0004m5-9U for qemu-devel@nongnu.org; Wed, 01 Dec 2010 06:31:15 -0500 Received: from mail.codesourcery.com ([38.113.113.100]:34667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PNktp-0004lX-Mc for qemu-devel@nongnu.org; Wed, 01 Dec 2010 06:31:02 -0500 From: Paul Brook 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 11:30:58 +0000 References: <90e8c0b7db1086c38283f684a159a892b4a66228.1291196789.git.amit.shah@redhat.com> In-Reply-To: <90e8c0b7db1086c38283f684a159a892b4a66228.1291196789.git.amit.shah@redhat.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201012011130.58630.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Amit Shah , Gerd Hoffmann , Juan Quintela > /* 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) Paul