aboutsummaryrefslogtreecommitdiff
path: root/hw/char
diff options
context:
space:
mode:
authorJing Liu <liujbjl@linux.vnet.ibm.com>2016-07-21 08:00:58 +0200
committerCornelia Huck <cornelia.huck@de.ibm.com>2017-05-04 10:34:37 +0200
commit4996241a4a9dc82509d3fed07b1ee51d4d37bce6 (patch)
tree4cd66fe4ef1a0bac92d76e5808020d103994cd67 /hw/char
parent2dc95b4cac5e8c68563c2e82ee9606896c54217c (diff)
s390x/3270: Add the TCP socket events handler for 3270
This introduces a chr_event handler to handle the 3270 connection and disconnection events. Signed-off-by: Jing Liu <liujbjl@linux.vnet.ibm.com> Reviewed-by: QingFeng Hao <haoqf@linux.vnet.ibm.com> Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'hw/char')
-rw-r--r--hw/char/terminal3270.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c
index 55eed5622a..450608e3c3 100644
--- a/hw/char/terminal3270.c
+++ b/hw/char/terminal3270.c
@@ -117,6 +117,32 @@ static void terminal_read(void *opaque, const uint8_t *buf, int size)
}
}
+static void chr_event(void *opaque, int event)
+{
+ Terminal3270 *t = opaque;
+ CcwDevice *ccw_dev = CCW_DEVICE(t);
+ SubchDev *sch = ccw_dev->sch;
+
+ /* Ensure the initial status correct, always reset them. */
+ t->in_len = 0;
+ t->out_len = 0;
+ t->handshake_done = false;
+
+ switch (event) {
+ case CHR_EVENT_OPENED:
+ /*
+ * 3270 does handshake firstly by the negotiate options in
+ * char-socket.c. Once qemu receives the terminal-type of the
+ * client, mark handshake done and trigger everything rolling again.
+ */
+ break;
+ case CHR_EVENT_CLOSED:
+ sch->curr_status.scsw.dstat = SCSW_DSTAT_DEVICE_END;
+ css_conditional_io_interrupt(sch);
+ break;
+ }
+}
+
static void terminal_init(EmulatedCcw3270Device *dev, Error **errp)
{
Terminal3270 *t = TERMINAL_3270(dev);
@@ -128,7 +154,7 @@ static void terminal_init(EmulatedCcw3270Device *dev, Error **errp)
}
terminal_available = true;
qemu_chr_fe_set_handlers(&t->chr, terminal_can_read,
- terminal_read, NULL, t, NULL, true);
+ terminal_read, chr_event, t, NULL, true);
}
static int read_payload_3270(EmulatedCcw3270Device *dev, uint32_t cda,