[libvirt] [PATCH v6 18/33] qemu_process: Catch process free before process stop

Chris Venteicher cventeic at redhat.com
Sun Jan 13 00:50:17 UTC 2019


Catch execution paths where qemuProcessQMPFree is called before
qemuProcessQMPStop then report error and force stop before proceeding.

Also added public function header and debug message.

Signed-off-by: Chris Venteicher <cventeic at redhat.com>
---
 src/qemu/qemu_process.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index fb14ed35f9..15a38144f5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8203,13 +8203,28 @@ static qemuMonitorCallbacks callbacks = {
 };
 
 
+/**
+ * qemuProcessQMPFree:
+ * @proc: Stores process and connection state
+ *
+ * Free process data structure.
+ */
 void
 qemuProcessQMPFree(qemuProcessQMPPtr proc)
 {
     if (!proc)
         return;
 
-    qemuProcessQMPStop(proc);
+    VIR_DEBUG("proc=%p, proc->mon=%p", proc, proc->mon);
+
+    /* This should never be non-NULL if we get here, but just in case... */
+    if (proc->mon || proc->pid) {
+        VIR_ERROR(_("Unexpected QEMU still active during process free"
+                    " emulator: %s, pid: %lld, mon: %p"),
+                  proc->binary, (long long)proc->pid, proc->mon);
+        qemuProcessQMPStop(proc);
+    }
+
     VIR_FREE(proc->binary);
     VIR_FREE(proc->libDir);
     VIR_FREE(proc->monpath);
-- 
2.17.1




More information about the libvir-list mailing list