From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NwyNF-0008Lt-PX for qemu-devel@nongnu.org; Wed, 31 Mar 2010 09:54:25 -0400 Received: from [140.186.70.92] (port=48646 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NwyNB-0008Fb-7l for qemu-devel@nongnu.org; Wed, 31 Mar 2010 09:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NwyMz-0002Gi-4i for qemu-devel@nongnu.org; Wed, 31 Mar 2010 09:54:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10960) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NwyMy-0002GT-S3 for qemu-devel@nongnu.org; Wed, 31 Mar 2010 09:54:09 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2VDs4WR031518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 31 Mar 2010 09:54:04 -0400 Message-ID: <4BB353F7.10207@redhat.com> Date: Wed, 31 Mar 2010 15:53:59 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 15/17] virtio-serial: Apps should consume all data that guest sends out / Fix virtio api abuse References: <1270020848-15526-1-git-send-email-amit.shah@redhat.com> <1270020848-15526-2-git-send-email-amit.shah@redhat.com> <1270020848-15526-3-git-send-email-amit.shah@redhat.com> <1270020848-15526-4-git-send-email-amit.shah@redhat.com> <1270020848-15526-5-git-send-email-amit.shah@redhat.com> <1270020848-15526-6-git-send-email-amit.shah@redhat.com> <1270020848-15526-7-git-send-email-amit.shah@redhat.com> <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> In-Reply-To: <1270020848-15526-16-git-send-email-amit.shah@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: Juan Quintela , qemu list , "Michael S. Tsirkin" > /* 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). cheers, Gerd