From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCmix-0007Am-Me for qemu-devel@nongnu.org; Thu, 31 Jul 2014 05:32:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCmis-0003Jx-8T for qemu-devel@nongnu.org; Thu, 31 Jul 2014 05:32:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCmis-0003Jh-0d for qemu-devel@nongnu.org; Thu, 31 Jul 2014 05:32:30 -0400 Date: Thu, 31 Jul 2014 10:32:24 +0100 From: "Richard W.M. Jones" Message-ID: <20140731093224.GB14001@redhat.com> References: <53D93EF9.3020505@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53D93EF9.3020505@windriver.com> Subject: Re: [Qemu-devel] questions about host side of virtio-serial List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chris Friesen Cc: Amit Shah , "qemu-devel@nongnu.org" On Wed, Jul 30, 2014 at 12:52:41PM -0600, Chris Friesen wrote: > Hi, > > I'm working on a native user of virtio-serial (ie, not going via the > qemu guest agent). > > The information at "http://www.linux-kvm.org/page/Virtio-serial_API" > does a good job of describing the guest side of things, but has very > little information about the host side of things. You might also want to read the libguestfs source code, since libguestfs is a major and long-time user of virtio-serial. In particular these files: src/launch-direct.c src/proto.c src/conn-socket.c daemon/proto.c src/launch-libvirt.c # if interested in using virtio-serial from libvirt > In particular, assuming that the host side is using a chardev mapped > to a unix socket: > > 1) Is there any way for the host app to get information about > whether or not the guest is reading the messages? (i.e. logically > equivalent to getting POLLHUP in the guest when the host app > disconnects.) No, I don't believe that is possible. It acts like a real serial port and throws away bytes when no one is listening (on both ends). > 2) Suppose the host sends a large message. The guest app reads a > portion of the message, then crashes. We respawn the guest app and > start reading again, but now we're in the middle of a message of > arbitrary size. Is there a recommended technique to re-sync the > host and guest? AFAIK that's either very difficult or impossible. Maybe with some kind of self-synchronizing protocol, or if you ran SLIP/PPP on top of the raw virtio-serial channel? In the libguestfs case we wouldn't even try to go there -- if something in the VM crashes we completely recreate the virtual machine from scratch. > 3) Same as 2, but the guest sending to the host and the host app > crashing partway through. > > 4) If nothing in the guest is reading the data, how much data can > the host send before it will get an error? It won't get an error - the sender will block. Except on ARM where there is a race condition in virtio-mmio causing writes to be thrown away (https://bugs.launchpad.net/qemu/+bug/1224444). > Is there a way to adjust this? Not as far as I know. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top