From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCrbc-00025s-Pc for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:45:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCrbV-0002bJ-TN for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:45:20 -0400 Received: from mail1.windriver.com ([147.11.146.13]:58523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCrbV-0002b3-Kw for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:45:13 -0400 Message-ID: <53DA5675.6010607@windriver.com> Date: Thu, 31 Jul 2014 08:45:09 -0600 From: Chris Friesen MIME-Version: 1.0 References: <53D93EF9.3020505@windriver.com> <20140731093224.GB14001@redhat.com> In-Reply-To: <20140731093224.GB14001@redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] questions about host side of virtio-serial List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" Cc: Amit Shah , "qemu-devel@nongnu.org" On 07/31/2014 03:32 AM, Richard W.M. Jones wrote: > On Wed, Jul 30, 2014 at 12:52:41PM -0600, Chris Friesen wrote: >> 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). With qemu 1.4.2 it blocks or returns EAGAIN if the guest tries to write to the char device, but the behaviour is different if the host tries to write to the unix socket. See 4 below. >> 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). I'm seeing behaviour that doesn't match what you describe. With nothing listening in the guest I can send a packet to the unix socket on the host and it gets accepted: connect(7, {sa_family=AF_FILE, sun_path="/var/lib/libvirt/qemu/cgcs.messaging.instance-00000004.sock"}, 61) = 0 sendto(7, "\r\360\255\272N\0instcgcs.server_grp\0cgcs.s"..., 78, 0, NULL, 0) = 78 Then, up in the guest I start a new process to read from the device and I can read the data that was sent in by the host. open("/dev/virtio-ports/cgcs.messaging", O_RDWR|O_NONBLOCK) = 3 read(3, "\r\360\255\272N\0instcgcs.server_grp\0cgcs.s"..., 10000) = 78 This is a VM started by openstack, the pertinent parameters are: -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/cgcs.messaging.instance-00000004.sock,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=cgcs.messaging Chris