Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KLbPM-0002D1-Ty for qemu-devel@nongnu.org; Wed, 23 Jul 2008 06:17:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KLbPK-0002CG-8J for qemu-devel@nongnu.org; Wed, 23 Jul 2008 06:17:18 -0400 Received: from [199.232.76.173] (port=38451 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLbPJ-0002Bm-D4 for qemu-devel@nongnu.org; Wed, 23 Jul 2008 06:17:17 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:28489) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KLbPJ-0006Nx-0W for qemu-devel@nongnu.org; Wed, 23 Jul 2008 06:17:17 -0400 Received: from mariner.uk.xensource.com ([10.80.2.22]) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id m6NAHCWx014144 for ; Wed, 23 Jul 2008 03:17:13 -0700 Received: from iwj by mariner.uk.xensource.com with local (Exim 4.63) (envelope-from ) id 1KLbPE-0001gI-4N for qemu-devel@nongnu.org; Wed, 23 Jul 2008 11:17:12 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18567.1320.117345.844400@mariner.uk.xensource.com> Date: Wed, 23 Jul 2008 11:17:12 +0100 Subject: Re: [Qemu-devel] [PATCH 2/3] Always use nonblocking mode for qemu_chr_open_fd. In-Reply-To: <4886FB17.5080202@suse.de> References: <488688E3.105@codemonkey.ws> <4886FB17.5080202@suse.de> From: Ian Jackson Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Anthony Liguori writes ("Re: [Qemu-devel] [PATCH 2/3] Always use nonblocking mode for qemu_chr_open_fd."): > This changes semantics a bit. Previously, using a pty would guarantee > that data is always written as qemu_chr_write does not perform any sort > of buffering. That depends on what the caller (that is, the internal device model which is using the char driver) does. In the case of the serial driver in our tree, the emulated serial port does not empty its simulated transmit shift register until the data has been accepted by the char driver - ie, actually delivered to whereever it is going. That is, the flow control is communicated back to the guest - perhaps not in the most optimal way, since perhaps it would be better to simulate modem flow control lines rather than playing games with making virtual time run slowly. But no data will be lost unless the guest chooses to throw it away - and the guest can get on with the rest of its life in the meantime. I'm afraid that this change (which is part of a general improvement to the flow control handling in hw/serial.c) hasn't made it upstream yet. But regardless, I think having the whole qemu process block while writing to a `slow' device like a pty (or a network connection for that matter) is generally wrong. I haven't searched for other callers, but if they don't offer a way to prevent the guest from attempting to write too much then I think that is a bug in that driver. Kevin Wolf writes ("Re: [Qemu-devel] [PATCH 2/3] Always use nonblocking mode for qemu_chr_open_fd."): > + if (strstart(filename, "nonblock:", &filename)) > + block = 0; This is definitely wrong, because the need for (non)blocking behaviour is determined statically by the code which is using the driver. Perhaps there should be two writing interfaces, qemu_chr_write and qemu_chr_write_(non)block. qemu_chr_write_block_fd would have to contain a select() or poll() loop since the fd needs to be in nonblocking mode for the reads to work correctly without races. Ian.