[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] qemu_agent: Ignore expected EOFs



https://bugzilla.redhat.com/show_bug.cgi?id=892079

One of my previous patches (f2a4e5f176c408) tried to fix crashing
libvirtd on domain detroy. However, we need to copy pattern from
qemuProcessHandleMonitorEOF() instead of decrementing reference
counter. The rationale for this is, if qemu process is dying due
to domain being destroyed, we obtain EOF on both the monitor and
agent sockets. However, if the exit is expected, qemuProcessStop
is called, which cleans both agent and monitor sockets up. We
want qemuAgentClose() to be called iff the EOF is not expected,
so we don't leak an FD and memory.
---
 src/qemu/qemu_process.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2f08215..b212752 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -133,8 +133,15 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
     virObjectLock(vm);
 
     priv = vm->privateData;
-    if (priv->agent == agent &&
-        !virObjectUnref(priv->agent))
+
+    if (priv->beingDestroyed) {
+        VIR_DEBUG("Domain is being destroyed, agent EOF is expected");
+        virObjectUnlock(vm);
+        qemuDriverUnlock(driver);
+        return;
+    }
+
+    if (priv->agent == agent)
         priv->agent = NULL;
 
     virObjectUnlock(vm);
-- 
1.8.0.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]