[libvirt] [PATCH v6 16/33] qemu_process: Cleanup qemuProcessQMP alloc function

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


qemuProcessQMPNew is one of the 4 public functions used to create and
manage a qemu process for QMP command exchanges outside of domain
operations.

Add descriptive comment block, Debug statement and make source
consistent with the cleanup / VIR_STEAL_PTR format used elsewhere.

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

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 91532c19ce..58842a0f1c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8220,6 +8220,18 @@ qemuProcessQMPFree(qemuProcessQMPPtr proc)
 }
 
 
+/**
+ * qemuProcessQMPNew:
+ * @binary: QEMU binary
+ * @libDir: Directory for process and connection artifacts
+ * @runUid: UserId for QEMU Process
+ * @runGid: GroupId for QEMU Process
+ * @forceTCG: Force TCG mode if true
+ *
+ * Allocate and initialize domain structure encapsulating
+ * QEMU Process state and monitor connection to QEMU
+ * for completing QMP Queries.
+ */
 qemuProcessQMPPtr
 qemuProcessQMPNew(const char *binary,
                   const char *libDir,
@@ -8227,24 +8239,31 @@ qemuProcessQMPNew(const char *binary,
                   gid_t runGid,
                   bool forceTCG)
 {
+    qemuProcessQMPPtr ret = NULL;
     qemuProcessQMPPtr proc = NULL;
 
+    VIR_DEBUG("exec=%s, libDir=%s, runUid=%u, runGid=%u, forceTCG=%d",
+              binary, libDir, runUid, runGid, forceTCG);
+
     if (VIR_ALLOC(proc) < 0)
-        goto error;
+        goto cleanup;
 
     if (VIR_STRDUP(proc->binary, binary) < 0 ||
         VIR_STRDUP(proc->libDir, libDir) < 0)
-        goto error;
+        goto cleanup;
 
     proc->runUid = runUid;
     proc->runGid = runGid;
     proc->forceTCG = forceTCG;
 
-    return proc;
+    VIR_STEAL_PTR(ret, proc);
 
- error:
+ cleanup:
     qemuProcessQMPFree(proc);
-    return NULL;
+
+    VIR_DEBUG("ret=%p", ret);
+
+    return ret;
 }
 
 
-- 
2.17.1




More information about the libvir-list mailing list