From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: peter.maydell@linaro.org
Cc: Heinz Graalfs <graalfs@linux.vnet.ibm.com>,
qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com,
jfrei@linux.vnet.ibm.com,
Cornelia Huck <cornelia.huck@de.ibm.com>
Subject: [Qemu-devel] [PULL 3/5] s390x/sclpconsole-lm: truncate input if line is too long
Date: Wed, 5 Nov 2014 16:48:14 +0100 [thread overview]
Message-ID: <1415202496-27190-4-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1415202496-27190-1-git-send-email-cornelia.huck@de.ibm.com>
From: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
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 <graalfs@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
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
next prev parent reply other threads:[~2014-11-05 15:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-05 15:48 [Qemu-devel] [PULL 0/5] s390x fixes for 2.2 Cornelia Huck
2014-11-05 15:48 ` [Qemu-devel] [PULL 1/5] s390x/kvm: Fix opcode decoding for eb instruction handler Cornelia Huck
2014-11-05 15:48 ` [Qemu-devel] [PULL 2/5] s390x/kvm: Fix warning from sparse Cornelia Huck
2014-11-05 15:48 ` Cornelia Huck [this message]
2014-11-05 15:48 ` [Qemu-devel] [PULL 4/5] s390x/sclpconsole-lm: Fix hanging SCLP line mode console Cornelia Huck
2014-11-05 15:48 ` [Qemu-devel] [PULL 5/5] s390x/sclpconsole: Avoid hanging SCLP ASCII console Cornelia Huck
2014-11-10 9:17 ` [Qemu-devel] [PULL 0/5] s390x fixes for 2.2 Christian Borntraeger
2014-11-10 16:28 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415202496-27190-4-git-send-email-cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=graalfs@linux.vnet.ibm.com \
--cc=jfrei@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).