提交 4ab312f7 编写于 作者: J Jan Kiszka 提交者: Anthony Liguori

mux-term: Fix timestamp association

So far a new timestamp was generated *after* a full line had been
printed. Fix this.
Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 2d22959d
...@@ -238,6 +238,7 @@ typedef struct { ...@@ -238,6 +238,7 @@ typedef struct {
int prod[MAX_MUX]; int prod[MAX_MUX];
int cons[MAX_MUX]; int cons[MAX_MUX];
int timestamps; int timestamps;
int linestart;
int64_t timestamps_start; int64_t timestamps_start;
} MuxDriver; } MuxDriver;
...@@ -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)
int i; int i;
ret = 0; ret = 0;
for(i = 0; i < len; i++) { for (i = 0; i < len; i++) {
ret += d->drv->chr_write(d->drv, buf+i, 1); if (d->linestart) {
if (buf[i] == '\n') {
char buf1[64]; char buf1[64];
int64_t ti; int64_t ti;
int secs; 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)
secs % 60, secs % 60,
(int)(ti % 1000)); (int)(ti % 1000));
d->drv->chr_write(d->drv, (uint8_t *)buf1, strlen(buf1)); 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) ...@@ -360,6 +365,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
case 't': case 't':
d->timestamps = !d->timestamps; d->timestamps = !d->timestamps;
d->timestamps_start = -1; d->timestamps_start = -1;
d->linestart = 0;
break; break;
} }
} else if (ch == term_escape_char) { } else if (ch == term_escape_char) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册