aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@web.de>2009-06-15 22:25:34 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-16 15:18:37 -0500
commit4ab312f793fe9202299966de98d67d9574c572d4 (patch)
tree61416ebb849251b3e3b92c92a219c38ed82651b3
parent2d22959d61fa866d2bbe310b61539da98bb47917 (diff)
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>
-rw-r--r--qemu-char.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/qemu-char.c b/qemu-char.c
index d82a64fc57..287e0cd326 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -238,6 +238,7 @@ typedef struct {
int prod[MAX_MUX];
int cons[MAX_MUX];
int timestamps;
+ int linestart;
int64_t timestamps_start;
} MuxDriver;
@@ -252,9 +253,8 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
int i;
ret = 0;
- for(i = 0; i < len; i++) {
- ret += d->drv->chr_write(d->drv, buf+i, 1);
- if (buf[i] == '\n') {
+ for (i = 0; i < len; i++) {
+ if (d->linestart) {
char buf1[64];
int64_t ti;
int secs;
@@ -271,6 +271,11 @@ static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
secs % 60,
(int)(ti % 1000));
d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1));
+ d->linestart = 0;
+ }
+ ret += d->drv->chr_write(d->drv, buf+i, 1);
+ if (buf[i] == '\n') {
+ d->linestart = 1;
}
}
}
@@ -360,6 +365,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
case 't':
d->timestamps = !d->timestamps;
d->timestamps_start = -1;
+ d->linestart = 0;
break;
}
} else if (ch == term_escape_char) {