Commit 2d22959d61fa866d2bbe310b61539da98bb47917

Authored by Jan Kiszka
Committed by Anthony Liguori
1 parent 759754f0

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>
Showing 1 changed file with 10 additions and 10 deletions
qemu-char.c
... ... @@ -219,8 +219,6 @@ static CharDriverState *qemu_chr_open_null(void)
219 219 }
220 220  
221 221 /* MUX driver for serial I/O splitting */
222   -static int term_timestamps;
223   -static int64_t term_timestamps_start;
224 222 #define MAX_MUX 4
225 223 #define MUX_BUFFER_SIZE 32 /* Must be a power of 2. */
226 224 #define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1)
... ... @@ -239,6 +237,8 @@ typedef struct {
239 237 unsigned char buffer[MAX_MUX][MUX_BUFFER_SIZE];
240 238 int prod[MAX_MUX];
241 239 int cons[MAX_MUX];
  240 + int timestamps;
  241 + int64_t timestamps_start;
242 242 } MuxDriver;
243 243  
244 244  
... ... @@ -246,7 +246,7 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
246 246 {
247 247 MuxDriver *d = chr->opaque;
248 248 int ret;
249   - if (!term_timestamps) {
  249 + if (!d->timestamps) {
250 250 ret = d->drv->chr_write(d->drv, buf, len);
251 251 } else {
252 252 int i;
... ... @@ -260,9 +260,9 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
260 260 int secs;
261 261  
262 262 ti = qemu_get_clock(rt_clock);
263   - if (term_timestamps_start == -1)
264   - term_timestamps_start = ti;
265   - ti -= term_timestamps_start;
  263 + if (d->timestamps_start == -1)
  264 + d->timestamps_start = ti;
  265 + ti -= d->timestamps_start;
266 266 secs = ti / 1000;
267 267 snprintf(buf1, sizeof(buf1),
268 268 "[%02d:%02d:%02d.%03d] ",
... ... @@ -357,10 +357,10 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
357 357 chr->focus = 0;
358 358 mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_IN);
359 359 break;
360   - case 't':
361   - term_timestamps = !term_timestamps;
362   - term_timestamps_start = -1;
363   - break;
  360 + case 't':
  361 + d->timestamps = !d->timestamps;
  362 + d->timestamps_start = -1;
  363 + break;
364 364 }
365 365 } else if (ch == term_escape_char) {
366 366 d->term_got_escape = 1;
... ...