Received: from eggs.gnu.org ([2001:4830:134:3::10]:54731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm2pC-0004Fl-Ay for qemu-devel@nongnu.org; Wed, 05 Nov 2014 10:48:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm2p1-0001hR-V7 for qemu-devel@nongnu.org; Wed, 05 Nov 2014 10:48:45 -0500 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:51515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm2p1-0001hA-NJ for qemu-devel@nongnu.org; Wed, 05 Nov 2014 10:48:35 -0500 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Nov 2014 15:48:34 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id CC8702190046 for ; Wed, 5 Nov 2014 15:48:07 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sA5FmXXF61800640 for ; Wed, 5 Nov 2014 15:48:33 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sA5FmUjk014985 for ; Wed, 5 Nov 2014 08:48:32 -0700 From: Cornelia Huck Date: Wed, 5 Nov 2014 16:48:16 +0100 Message-Id: <1415202496-27190-6-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1415202496-27190-1-git-send-email-cornelia.huck@de.ibm.com> References: <1415202496-27190-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PULL 5/5] s390x/sclpconsole: Avoid hanging SCLP ASCII console List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: Heinz Graalfs , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Cornelia Huck From: Heinz Graalfs Force recalculation of file descriptor sets for main loop's poll(), in order to be able to readd a possibly removed input file descriptor after can_read() returned 0 (zero). Signed-off-by: Heinz Graalfs Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/char/sclpconsole.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c index fca105d..79891df 100644 --- a/hw/char/sclpconsole.c +++ b/hw/char/sclpconsole.c @@ -36,6 +36,7 @@ typedef struct SCLPConsole { uint32_t iov_bs; /* offset in buf for char layer read operation */ uint32_t iov_data_len; /* length of byte stream in buffer */ uint32_t iov_sclp_rest; /* length of byte stream not read via SCLP */ + bool notify; /* qemu_notify_event() req'd if true */ } SCLPConsole; /* character layer call-back functions */ @@ -44,8 +45,12 @@ typedef struct SCLPConsole { static int chr_can_read(void *opaque) { SCLPConsole *scon = opaque; + int avail = SIZE_BUFFER_VT220 - scon->iov_data_len; - return SIZE_BUFFER_VT220 - scon->iov_data_len; + if (avail == 0) { + scon->notify = true; + } + return avail; } /* Send data from a char device over to the guest */ @@ -113,6 +118,10 @@ static void get_console_data(SCLPEvent *event, uint8_t *buf, size_t *size, cons->iov_sclp += avail; /* more data pending */ } + if (cons->notify) { + cons->notify = false; + qemu_notify_event(); + } } static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr, @@ -229,6 +238,7 @@ static void console_reset(DeviceState *dev) scon->iov_bs = 0; scon->iov_data_len = 0; scon->iov_sclp_rest = 0; + scon->notify = false; } static int console_exit(SCLPEvent *event) -- 1.7.9.5