[libvirt] [PATCH 2/5] qemu: monitor: set error flag even in OOM conditions

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Wed Apr 18 13:03:29 UTC 2018


lastError.code is used as flag in qemu monitor. Unfortunately
due to temporary OOM conditions (very unlikely through as thread local
error is allocated on first use) we can fail to set this flag
in case of monitor eofs/errors. This can cause hangs.

Let's make sure flag is always set in case eofs/errors.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
---
 src/qemu/qemu_monitor.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7b64752..e3fedd3 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -765,6 +765,11 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque)
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("Error while processing monitor IO"));
             virCopyLastError(&mon->lastError);
+
+            /* set error code if due to OOM conditions we fail to set it before */
+            if (mon->lastError.code == VIR_ERR_OK)
+                mon->lastError.code = VIR_ERR_INTERNAL_ERROR;
+
             virResetLastError();
         }
 
-- 
1.8.3.1




More information about the libvir-list mailing list