0a122b
From f917e135d99ab0749ab747b3abce45e78de8c479 Mon Sep 17 00:00:00 2001
0a122b
From: Amit Shah <amit.shah@redhat.com>
0a122b
Date: Fri, 14 Feb 2014 08:27:07 +0100
0a122b
Subject: [PATCH 3/3] monitor: Cleanup mon->outbuf on write error
0a122b
0a122b
RH-Author: Amit Shah <amit.shah@redhat.com>
0a122b
Message-id: <a12d1cd833d1021980196981ad66eb268e26e507.1392365234.git.amit.shah@redhat.com>
0a122b
Patchwork-id: 57275
0a122b
O-Subject: [RHEL 7.0 qemu-kvm PATCH 1/1] monitor: Cleanup mon->outbuf on write error
0a122b
Bugzilla: 1065225
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
0a122b
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
0a122b
0a122b
From: Stratos Psomadakis <psomas@grnet.gr>
0a122b
0a122b
In case monitor_flush() fails to write the contents of mon->outbuf to
0a122b
the output device, mon->outbuf is not cleaned up properly. Check the
0a122b
return code of the qemu_chr_fe_write() function and cleanup the outbuf
0a122b
if it fails.
0a122b
0a122b
References: http://lists.nongnu.org/archive/html/qemu-devel/2014-01/msg02890.html
0a122b
0a122b
Bugzilla: 1065225
0a122b
0a122b
Signed-off-by: Stratos Psomadakis <psomas@grnet.gr>
0a122b
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
0a122b
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
0a122b
(cherry picked from commit 056f49ff2cf645dc484956b00b65a3aa18a1a9a3)
0a122b
Signed-off-by: Amit Shah <amit.shah@redhat.com>
0a122b
---
0a122b
 monitor.c | 4 ++--
0a122b
 1 file changed, 2 insertions(+), 2 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 monitor.c |    4 ++--
0a122b
 1 files changed, 2 insertions(+), 2 deletions(-)
0a122b
0a122b
diff --git a/monitor.c b/monitor.c
0a122b
index 8f36f91..a6abfb5 100644
0a122b
--- a/monitor.c
0a122b
+++ b/monitor.c
0a122b
@@ -287,8 +287,8 @@ void monitor_flush(Monitor *mon)
0a122b
 
0a122b
     if (len && !mon->mux_out) {
0a122b
         rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len);
0a122b
-        if (rc == len) {
0a122b
-            /* all flushed */
0a122b
+        if ((rc < 0 && errno != EAGAIN) || (rc == len)) {
0a122b
+            /* all flushed or error */
0a122b
             QDECREF(mon->outbuf);
0a122b
             mon->outbuf = qstring_new();
0a122b
             return;
0a122b
-- 
0a122b
1.7.1
0a122b