Commit 4ab312f793fe9202299966de98d67d9574c572d4
Committed by
Anthony Liguori
1 parent
2d22959d
mux-term: Fix timestamp association
So far a new timestamp was generated *after* a full line had been printed. Fix this. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
9 additions
and
3 deletions
qemu-char.c
@@ -238,6 +238,7 @@ typedef struct { | @@ -238,6 +238,7 @@ typedef struct { | ||
238 | int prod[MAX_MUX]; | 238 | int prod[MAX_MUX]; |
239 | int cons[MAX_MUX]; | 239 | int cons[MAX_MUX]; |
240 | int timestamps; | 240 | int timestamps; |
241 | + int linestart; | ||
241 | int64_t timestamps_start; | 242 | int64_t timestamps_start; |
242 | } MuxDriver; | 243 | } MuxDriver; |
243 | 244 | ||
@@ -252,9 +253,8 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) | @@ -252,9 +253,8 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) | ||
252 | int i; | 253 | int i; |
253 | 254 | ||
254 | ret = 0; | 255 | ret = 0; |
255 | - for(i = 0; i < len; i++) { | ||
256 | - ret += d->drv->chr_write(d->drv, buf+i, 1); | ||
257 | - if (buf[i] == '\n') { | 256 | + for (i = 0; i < len; i++) { |
257 | + if (d->linestart) { | ||
258 | char buf1[64]; | 258 | char buf1[64]; |
259 | int64_t ti; | 259 | int64_t ti; |
260 | int secs; | 260 | int secs; |
@@ -271,6 +271,11 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) | @@ -271,6 +271,11 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) | ||
271 | secs % 60, | 271 | secs % 60, |
272 | (int)(ti % 1000)); | 272 | (int)(ti % 1000)); |
273 | d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1)); | 273 | d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1)); |
274 | + d->linestart = 0; | ||
275 | + } | ||
276 | + ret += d->drv->chr_write(d->drv, buf+i, 1); | ||
277 | + if (buf[i] == '\n') { | ||
278 | + d->linestart = 1; | ||
274 | } | 279 | } |
275 | } | 280 | } |
276 | } | 281 | } |
@@ -360,6 +365,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch) | @@ -360,6 +365,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch) | ||
360 | case 't': | 365 | case 't': |
361 | d->timestamps = !d->timestamps; | 366 | d->timestamps = !d->timestamps; |
362 | d->timestamps_start = -1; | 367 | d->timestamps_start = -1; |
368 | + d->linestart = 0; | ||
363 | break; | 369 | break; |
364 | } | 370 | } |
365 | } else if (ch == term_escape_char) { | 371 | } else if (ch == term_escape_char) { |