diff options
author | Jan Kiszka <jan.kiszka@web.de> | 2009-06-15 22:25:30 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-06-16 15:18:37 -0500 |
commit | 2d22959d61fa866d2bbe310b61539da98bb47917 (patch) | |
tree | 57c284adc71992bed27c8770e59e3261d42e2884 | |
parent | 759754f01ff64d5b85d7e7357b9e77e8617a8e41 (diff) | |
download | qemu-2d22959d61fa866d2bbe310b61539da98bb47917.tar.gz qemu-2d22959d61fa866d2bbe310b61539da98bb47917.tar.bz2 qemu-2d22959d61fa866d2bbe310b61539da98bb47917.zip |
mux-term: Localize timestamps
As we can have multiple multiplexed terminals, timestamp control and
tracking should better take place per MuxDriver.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | qemu-char.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/qemu-char.c b/qemu-char.c index a8afe94fa7..d82a64fc57 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -219,8 +219,6 @@ static CharDriverState *qemu_chr_open_null(void) } /* MUX driver for serial I/O splitting */ -static int term_timestamps; -static int64_t term_timestamps_start; #define MAX_MUX 4 #define MUX_BUFFER_SIZE 32 /* Must be a power of 2. */ #define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1) @@ -239,6 +237,8 @@ typedef struct { unsigned char buffer[MAX_MUX][MUX_BUFFER_SIZE]; int prod[MAX_MUX]; int cons[MAX_MUX]; + int timestamps; + int64_t timestamps_start; } MuxDriver; @@ -246,7 +246,7 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) { MuxDriver *d = chr->opaque; int ret; - if (!term_timestamps) { + if (!d->timestamps) { ret = d->drv->chr_write(d->drv, buf, len); } else { int i; @@ -260,9 +260,9 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) int secs; ti = qemu_get_clock(rt_clock); - if (term_timestamps_start == -1) - term_timestamps_start = ti; - ti -= term_timestamps_start; + if (d->timestamps_start == -1) + d->timestamps_start = ti; + ti -= d->timestamps_start; secs = ti / 1000; snprintf(buf1, sizeof(buf1), "[%02d:%02d:%02d.%03d] ", @@ -357,10 +357,10 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch) chr->focus = 0; mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_IN); break; - case 't': - term_timestamps = !term_timestamps; - term_timestamps_start = -1; - break; + case 't': + d->timestamps = !d->timestamps; + d->timestamps_start = -1; + break; } } else if (ch == term_escape_char) { d->term_got_escape = 1; |