From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=35383 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ps6pp-0003sy-6y for qemu-devel@nongnu.org; Wed, 23 Feb 2011 00:00:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ps6po-0008Jd-Ds for qemu-devel@nongnu.org; Wed, 23 Feb 2011 00:00:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ps6po-0008JV-3Z for qemu-devel@nongnu.org; Wed, 23 Feb 2011 00:00:20 -0500 Date: Wed, 23 Feb 2011 10:29:44 +0530 From: Amit Shah Message-ID: <20110223045944.GA9886@amit-x200.redhat.com> References: <4D643B77.60109@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D643B77.60109@linux.vnet.ibm.com> Subject: [Qemu-devel] Re: virtio-serial semantics for binary data and guest agents List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: Anthony Liguori , "qemu-devel@nongnu.org Developers" , Adam Litke On (Tue) 22 Feb 2011 [16:40:55], Michael Roth wrote: > If something in the guest is attempting to read/write from the > virtio-serial device, and nothing is connected to virtio-serial's > host character device (say, a socket) > > 1. writes will block until something connect()s, at which point the > write will succeed > > 2. reads will always return 0 until something connect()s, at which > point the reads will block until there's data > > This makes it difficult (impossible?) to implement the notion of > connect/disconnect or open/close over virtio-serial without layering > another protocol on top using hackish things like length-encoded > payloads or sentinel values to determine the end of one > RPC/request/response/session and the start of the next. > > For instance, if the host side disconnects, then reconnects before > we read(), we may never get the read()=0, and our FD remains valid. > Whereas with a tcp/unix socket our FD is no longer valid, and the > read()=0 is an event we can check for at any point after the other > end does a close/disconnect. There's SIGIO support, so host connect-disconnect notifications can be caught via the signal. Also, nonblocking reads/writes will return -EPIPE if the host-side connection is not up. Amit