[PATCH RFC 17/22] qemu_process: Cleanup qemuProcessStopQmp function

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

 



qemuProcessStopQmp is one of the 4 public functions used to create and
manage a Qemu process for QMP command exchanges.

Add comment header and debug message.

Other minor code formatting cleanup.

No change in functionality is intended.

Signed-off-by: Chris Venteicher <cventeic@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5ff7d6878c..27a959cf9d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8360,14 +8360,27 @@ qemuProcessStartQmp(qemuProcessPtr proc)
     goto cleanup;
 }
 
-
-void
-qemuProcessStopQmp(qemuProcessPtr proc)
+/**
+ * qemuProcessStop:
+ * @proc: Stores Process and Connection State
+ *
+ * Stop Monitor Connection and QEMU Process
+ */
+void qemuProcessStopQmp(qemuProcessPtr proc)
 {
-    if (proc->mon)
-        virObjectUnlock(proc->mon);
-    qemuMonitorClose(proc->mon);
-    proc->mon = NULL;
+    qemuMonitorPtr mon = NULL;
+
+    if (!proc)
+        return;
+
+    VIR_DEBUG("Shutting down proc=%p emulator=%s mon=%p pid=%lld",
+              proc, proc->binary, proc->mon, (long long)proc->pid);
+
+    if ((mon = QEMU_PROCESS_MONITOR(proc))) {
+        virObjectUnlock(mon);
+        qemuMonitorClose(mon);
+        proc->mon = NULL;
+    }
 
     virCommandAbort(proc->cmd);
     virCommandFree(proc->cmd);
@@ -8388,7 +8401,9 @@ qemuProcessStopQmp(qemuProcessPtr proc)
                       virStrerror(errno, ebuf, sizeof(ebuf)));
 
     }
+
     if (proc->pidfile)
         unlink(proc->pidfile);
+
     proc->pid = 0;
 }
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux