From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nz5BI-0005Hs-7m for qemu-devel@nongnu.org; Tue, 06 Apr 2010 05:34:48 -0400 Received: from [140.186.70.92] (port=52530 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nz5BG-0005Gm-1Z for qemu-devel@nongnu.org; Tue, 06 Apr 2010 05:34:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nz5B9-0008RQ-Fj for qemu-devel@nongnu.org; Tue, 06 Apr 2010 05:34:45 -0400 Received: from mx20.gnu.org ([199.232.41.8]:11307) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nz5B9-0008RM-Cg for qemu-devel@nongnu.org; Tue, 06 Apr 2010 05:34:39 -0400 Received: from mail.codesourcery.com ([38.113.113.100]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nz5B8-0000wt-St for qemu-devel@nongnu.org; Tue, 06 Apr 2010 05:34:39 -0400 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH 1/5] char: Let the caller know how many bytes were written in case of incomplete writes Date: Tue, 6 Apr 2010 10:34:29 +0100 References: <1270471538-31275-1-git-send-email-amit.shah@redhat.com> <201004051733.38629.paul@codesourcery.com> <20100406032429.GB4135@amit-x200.redhat.com> In-Reply-To: <20100406032429.GB4135@amit-x200.redhat.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201004061034.30213.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: Juan Quintela , qemu-devel@nongnu.org, Gerd Hoffmann > On (Mon) Apr 05 2010 [17:33:38], Paul Brook wrote: > > > There might be cases where a few bytes would have been sent out to char > > > devices and some not. Currently the return values from qemu_chr_write() > > > to char devs are only -1, indicating an error, or the complete length > > > of the string passed. > > > > > > Make 'len' a pointer instead, and indicate how much of the string was > > > written. The return value will either be the same as 'len' or a > > > negative number indicating an error condition. > > > > This seems wrong. We should not be getting recoverable errors. > > I was thinking of adding a bool to CharDriverState to indicate if EAGAIN > should be reported to the writer. This can be conveyed at the time of > doing qemu_chr_add_handlers(). > > It would certainly be beneficial for consumers of virtio-serial to be > notified of -EAGAIN so that the guest can be throttled till the chardev > catches up with the data being sent. EAGAIN should only ever occur if no bytes are written. If a stall condition occurs after some data has been written (and we allow partial completion) then this is indicated by returning a short count. Paul