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 | 238 | int prod[MAX_MUX]; |
| 239 | 239 | int cons[MAX_MUX]; |
| 240 | 240 | int timestamps; |
| 241 | + int linestart; | |
| 241 | 242 | int64_t timestamps_start; |
| 242 | 243 | } MuxDriver; |
| 243 | 244 | |
| ... | ... | @@ -252,9 +253,8 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) |
| 252 | 253 | int i; |
| 253 | 254 | |
| 254 | 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 | 258 | char buf1[64]; |
| 259 | 259 | int64_t ti; |
| 260 | 260 | int secs; |
| ... | ... | @@ -271,6 +271,11 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len) |
| 271 | 271 | secs % 60, |
| 272 | 272 | (int)(ti % 1000)); |
| 273 | 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 | 365 | case 't': |
| 361 | 366 | d->timestamps = !d->timestamps; |
| 362 | 367 | d->timestamps_start = -1; |
| 368 | + d->linestart = 0; | |
| 363 | 369 | break; |
| 364 | 370 | } |
| 365 | 371 | } else if (ch == term_escape_char) { | ... | ... |