From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9jX4-0005Lh-GE for qemu-devel@nongnu.org; Wed, 05 May 2010 14:41:18 -0400 Received: from [140.186.70.92] (port=54692 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9jX1-0005K9-7k for qemu-devel@nongnu.org; Wed, 05 May 2010 14:41:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9jWw-0005Wa-T1 for qemu-devel@nongnu.org; Wed, 05 May 2010 14:41:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27300) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9jWw-0005WE-LM for qemu-devel@nongnu.org; Wed, 05 May 2010 14:41:10 -0400 Message-ID: <4BE1BBB3.8050006@redhat.com> Date: Wed, 05 May 2010 20:40:51 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: <1273009170-17530-1-git-send-email-amit.shah@redhat.com> <1273009170-17530-2-git-send-email-amit.shah@redhat.com> <1273009170-17530-3-git-send-email-amit.shah@redhat.com> <1273009170-17530-4-git-send-email-amit.shah@redhat.com> <1273009170-17530-5-git-send-email-amit.shah@redhat.com> <4BE16FB5.6040708@codemonkey.ws> In-Reply-To: <4BE16FB5.6040708@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Amit Shah , Paul Brook , qemu list , Juan Quintela >> + return s->chr_write_nb(s, buf, len); >> +} > > I really dislike the idea of adding another function for this. Having a explicit function for non-blocking mode IMHO is much better. It makes things more clear when reading the code. Previous approach was to check for O_NONBLOCK (extra syscall) and behave differently depending on whenever it is set or not (too much hidden magic). > Can you > explain why you need this functionality for virtio-console and why this > functionality isn't needed for everything else? virtio-console is just the first user. 16550 emulation can use that too. With the blocking interface you'll stall the guest (sitting in the blocking write syscall) in case the outgoing pipe is full. With the non-blocking interface you can simply delay the "you can send more data" signal (update status register + raise IRQ) until you can actually accept more data. Meanwhile the guest can continue to run and do something else. Basically it allows to implement sane flow control. cheers, Gerd