From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgFOj-0006Nu-TB for qemu-devel@nongnu.org; Thu, 29 Dec 2011 07:47:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgFOi-0000aA-Id for qemu-devel@nongnu.org; Thu, 29 Dec 2011 07:47:53 -0500 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:36897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgFOi-0000Zc-9f for qemu-devel@nongnu.org; Thu, 29 Dec 2011 07:47:52 -0500 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 29 Dec 2011 12:47:49 -0000 Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBTClkd02760748 for ; Thu, 29 Dec 2011 12:47:46 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost.localdomain [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBTClkdb021751 for ; Thu, 29 Dec 2011 05:47:46 -0700 Message-ID: <4EFC616F.4060806@de.ibm.com> Date: Thu, 29 Dec 2011 13:47:43 +0100 From: Christian Borntraeger MIME-Version: 1.0 References: <4EE9EBB9.9020300@de.ibm.com> In-Reply-To: <4EE9EBB9.9020300@de.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCHv2] Fix virtio-console failure on unconnected pty List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: "qemu-devel@nongnu.org" , Alexander Graf From: Christian Borntraeger when I tried qemu with -virtio-console pty the guest hangs and attaching on /dev/pts/ does not return anything if the attachement is too late. Turns out that the console is already throttled and the guest is heavily spinning but get_buf never returns the buffer. There seems to be no way for the console to unthrottle the port. For the virtio-serial use case we dont want to loose data but for the console case we better drop data instead of "killing" the guest console. If we get chardev->frontend notification and a better behaving virtio-console we can revert this fix. Signed-off-by: Christian Borntraeger --- hw/virtio-serial-bus.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) Index: b/hw/virtio-serial-bus.c =================================================================== --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -163,7 +163,19 @@ static void do_flush_queued_data(VirtIOS abort(); } if (ret == -EAGAIN || (ret >= 0 && ret < buf_size)) { - virtio_serial_throttle_port(port, true); + /* + * this is a temporary check until chardevs can signal to + * frontends that they are writable again. This prevents + * the console from going into throttled mode (forever) + * if virtio-console is connected to a pty without a + * listener. Otherwise the guest spins forever. + * We can revert this if + * 1: chardevs can notify frondends + * 2: the guest driver does not spin in these cases + */ + if (!info->is_console) { + virtio_serial_throttle_port(port, true); + } port->iov_idx = i; if (ret > 0) { port->iov_offset += ret;