From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NwyaT-0003a6-KA for qemu-devel@nongnu.org; Wed, 31 Mar 2010 10:08:05 -0400 Received: from [140.186.70.92] (port=38601 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NwyaQ-0003OE-3x for qemu-devel@nongnu.org; Wed, 31 Mar 2010 10:08:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NwyaE-0005kD-UO for qemu-devel@nongnu.org; Wed, 31 Mar 2010 10:07:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15279) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NwyaE-0005i5-8j for qemu-devel@nongnu.org; Wed, 31 Mar 2010 10:07:50 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2VE7eaP028018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 31 Mar 2010 10:07:40 -0400 Date: Wed, 31 Mar 2010 19:36:12 +0530 From: Amit Shah Subject: Re: [Qemu-devel] [PATCH 15/17] virtio-serial: Apps should consume all data that guest sends out / Fix virtio api abuse Message-ID: <20100331140612.GA18283@amit-x200.redhat.com> References: <1270020848-15526-8-git-send-email-amit.shah@redhat.com> <1270020848-15526-9-git-send-email-amit.shah@redhat.com> <1270020848-15526-10-git-send-email-amit.shah@redhat.com> <1270020848-15526-11-git-send-email-amit.shah@redhat.com> <1270020848-15526-12-git-send-email-amit.shah@redhat.com> <1270020848-15526-13-git-send-email-amit.shah@redhat.com> <1270020848-15526-14-git-send-email-amit.shah@redhat.com> <1270020848-15526-15-git-send-email-amit.shah@redhat.com> <1270020848-15526-16-git-send-email-amit.shah@redhat.com> <4BB353F7.10207@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4BB353F7.10207@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Juan Quintela , qemu list , "Michael S. Tsirkin" On (Wed) Mar 31 2010 [15:53:59], Gerd Hoffmann wrote: >> /* Callback function that's called when the guest sends us data */ >> -static size_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) >> +static void flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) >> { >> VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); >> - ssize_t ret; >> >> - ret = qemu_chr_write(vcon->chr, buf, len); >> - >> - return ret< 0 ? 0 : ret; >> + qemu_chr_write(vcon->chr, buf, len); >> } > > Ok, so we loose data in case qemu_chr_write wasn't able to write out all > data? Nice opportunity to show flow control in action here ;) > > On failed+partial writes just put the remaining data into a buffer and > throttle the port until all buffered data has been successfully written > to the chardev. > > Incremental patch is fine to avoid the chicken-egg issue (throttling is > added by patch #17). Yes, that's what I intend to do in a later patch (series). Amit