Commit 056f49ff authored by Stratos Psomadakis's avatar Stratos Psomadakis Committed by Luiz Capitulino

monitor: Cleanup mon->outbuf on write error

In case monitor_flush() fails to write the contents of mon->outbuf to
the output device, mon->outbuf is not cleaned up properly. Check the
return code of the qemu_chr_fe_write() function and cleanup the outbuf
if it fails.

References: default avatarStratos Psomadakis <>
Signed-off-by: default avatarDimitris Aragiorgis <>
Signed-off-by: default avatarLuiz Capitulino <>
parent 57d3e1b3
......@@ -288,8 +288,8 @@ void monitor_flush(Monitor *mon)
if (len && !mon->mux_out) {
rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len);
if (rc == len) {
/* all flushed */
if ((rc < 0 && errno != EAGAIN) || (rc == len)) {
/* all flushed or error */
mon->outbuf = qstring_new();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment