[libvirt] [PATCH] qemu: Don't send any monitor commands afer SHUTDOWN event

Michal Privoznik mprivozn at redhat.com
Fri Jan 19 09:02:45 UTC 2018


After aeda1b8c56dc5 we tried to stop reporting I/O errors on
expected monitor HUP. We've achieved that by not setting
mon->lastError once we've received SHUTDOWN event. However, this
makes us to deadlock in case there's thread that enters the
monitor after the event is received. The problem is, we're no
longer setting mon->lastError and therefore qemuMonitorSend()
does not return early and continues execution until virCondWait()
(which will never wake up).

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_monitor.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 85c7d68a1..9f3e3eb14 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1063,7 +1063,7 @@ qemuMonitorSend(qemuMonitorPtr mon,
 {
     int ret = -1;
 
-    /* Check whether qemu quit unexpectedly */
+    /* Check whether qemu quit unexpectedly, */
     if (mon->lastError.code != VIR_ERR_OK) {
         VIR_DEBUG("Attempt to send command while error is set %s",
                   NULLSTR(mon->lastError.message));
@@ -1071,6 +1071,12 @@ qemuMonitorSend(qemuMonitorPtr mon,
         return -1;
     }
 
+    /* or expectedly. */
+    if (mon->willhangup) {
+        VIR_DEBUG("Attempt to send command while domain is shutting down");
+        return -1;
+    }
+
     mon->msg = msg;
     qemuMonitorUpdateWatch(mon);
 
-- 
2.13.6




More information about the libvir-list mailing list