Skip to contentSkip to conversation

Additional s390x fixes for 2.2

PATCH New Cornelia Huck 1 participant 4 messages Nov 4, 2014

lore
Share & tools
lore
#0 lore raw

cover Additional s390x fixes for 2.2

Three further fixes going on top of what I sent in <[email protected]>, this time dealing with the sclp consoles (line mode and ascii).

I plan to send a pull request with all five patches tomorrow.

Heinz Graalfs (3):
s390x/sclpconsole-lm: truncate input if line is too long s390x/sclpconsole-lm: Fix hanging SCLP line mode console s390x/sclpconsole: Avoid hanging SCLP ASCII console

 hw/char/sclpconsole-lm.c |   12 ++++++++----
 hw/char/sclpconsole.c    |   12 +++++++++++-
 2 files changed, 19 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/3 s390x/sclpconsole-lm: Fix hanging SCLP line mode console

From: Heinz Graalfs <[email protected]>

Trigger recalculating sets of file descriptors for the main loop's poll() in order to make sure a possibly removed FD 0 from the poll() file descriptor array is re-added. FD 0 is removed from the decriptor array when the console's can_read() callback returns 0.

---
 hw/char/sclpconsole-lm.c |    1 +
 1 file changed, 1 insertion(+)
hw/char/sclpconsole-lm.c +1 -0
index 605dd50..a9f5e62 100644
@@ -128,6 +128,7 @@ static int get_console_data(SCLPEvent *event, uint8_t *buf, size_t *size,
     cons->length = 0;
     /* data provided and no more data pending */
     event->event_pending = false;
+    qemu_notify_event();
     return 0;
 }
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/3 s390x/sclpconsole-lm: truncate input if line is too long

In reply to Cornelia Huck

From: Heinz Graalfs <[email protected]>

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.

---
 hw/char/sclpconsole-lm.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
hw/char/sclpconsole-lm.c +7 -4
index 80dd0a9..605dd50 100644
@@ -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) {
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/3 s390x/sclpconsole: Avoid hanging SCLP ASCII console

In reply to Cornelia Huck

From: Heinz Graalfs <[email protected]>

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).

---
 hw/char/sclpconsole.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
hw/char/sclpconsole.c +11 -1
index fca105d..79891df 100644
@@ -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)
Signature · 1 line
1.7.9.5