From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm2pC-0004Fz-Ay for qemu-devel@nongnu.org; Wed, 05 Nov 2014 10:48:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm2p1-0001gv-0f for qemu-devel@nongnu.org; Wed, 05 Nov 2014 10:48:45 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:60998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm2p0-0001gd-NE for qemu-devel@nongnu.org; Wed, 05 Nov 2014 10:48:34 -0500 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Nov 2014 15:48:33 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 56B5B2190045 for ; Wed, 5 Nov 2014 15:48:05 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sA5FmULT14483840 for ; Wed, 5 Nov 2014 15:48:30 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 sA5FmS04014804 for ; Wed, 5 Nov 2014 08:48:30 -0700 From: Cornelia Huck Date: Wed, 5 Nov 2014 16:48:14 +0100 Message-Id: <1415202496-27190-4-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 3/5] s390x/sclpconsole-lm: truncate input if line is too long 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 As the SCLP line mode console input length is limited by the available SCCB buffer space, it might lock up if the input does not fit into the buffer. With this patch, characters that don't fit are 'eaten' up to the next CR/LF and the input line is sent truncated to the guest. Signed-off-by: Heinz Graalfs Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/char/sclpconsole-lm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 80dd0a9..605dd50 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -52,7 +52,8 @@ typedef struct SCLPConsoleLM { * event_pending is set when a newline character is encountered * * The maximum command line length is limited by the maximum - * space available in an SCCB + * space available in an SCCB. Line mode console input is sent + * truncated to the guest in case it doesn't fit into the SCCB. */ static int chr_can_read(void *opaque) @@ -61,10 +62,8 @@ static int chr_can_read(void *opaque) if (scon->event.event_pending) { return 0; - } else if (SIZE_CONSOLE_BUFFER - scon->length) { - return 1; } - return 0; + return 1; } static void chr_read(void *opaque, const uint8_t *buf, int size) @@ -78,6 +77,10 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) sclp_service_interrupt(0); return; } + if (scon->length == SIZE_CONSOLE_BUFFER) { + /* Eat the character, but still process CR and LF. */ + return; + } scon->buf[scon->length] = *buf; scon->length += 1; if (scon->echo) { -- 1.7.9.5