Received: from eggs.gnu.org ([2001:4830:134:3::10]:38875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XledR-0000Vh-35 for qemu-devel@nongnu.org; Tue, 04 Nov 2014 08:59:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XledH-0007Uz-W3 for qemu-devel@nongnu.org; Tue, 04 Nov 2014 08:59:01 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:35472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XledH-0007Uj-Ls for qemu-devel@nongnu.org; Tue, 04 Nov 2014 08:58:51 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Nov 2014 13:58:50 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7FEBD1B08051 for ; Tue, 4 Nov 2014 13:58:51 +0000 (GMT) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sA4Dwjbj54394880 for ; Tue, 4 Nov 2014 13:58:45 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sA4Dwi6T002216 for ; Tue, 4 Nov 2014 06:58:45 -0700 From: Cornelia Huck Date: Tue, 4 Nov 2014 14:58:34 +0100 Message-Id: <1415109516-30435-2-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1415109516-30435-1-git-send-email-cornelia.huck@de.ibm.com> References: <1415109516-30435-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH 1/3] s390x/sclpconsole-lm: truncate input if line is too long List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Heinz Graalfs , agraf@suse.de 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