@@ -138,7 +138,20 @@ static int qemu_chr_write_buffer(Chardev *s,
}
}
if (*offset > 0) {
+ /*
+ * If some data was written by backend, we should
+ * only log what was actually written. This method
+ * may be invoked again to write the remaining
+ * method, thus we'll log the remainder at that time.
+ */
qemu_chr_write_log(s, buf, *offset);
+ } else if (res < 0) {
+ /*
+ * If a fatal error was reported by the backend,
+ * assume this method won't be invoked again with
+ * this buffer, so log it all right away.
+ */
+ qemu_chr_write_log(s, buf, len);
}
qemu_mutex_unlock(&s->chr_write_lock);