[libvirt] [PATCH RFC 16/22] qemu_process: Cleanup qemuProcess alloc function

Chris Venteicher posted 22 patches 6 years ago
[libvirt] [PATCH RFC 16/22] qemu_process: Cleanup qemuProcess alloc function
Posted by Chris Venteicher 6 years ago
qemuProcessNew 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.

No functional changes are made.

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

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 55a092ecbb..5ff7d6878c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8097,6 +8097,18 @@ qemuProcessFree(qemuProcessPtr proc)
 }
 
 
+/**
+ * qemuProcessNew:
+ * @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.
+ */
 qemuProcessPtr
 qemuProcessNew(const char *binary,
                const char *libDir,
@@ -8104,25 +8116,29 @@ qemuProcessNew(const char *binary,
                gid_t runGid,
                bool forceTCG)
 {
+    qemuProcessPtr ret = NULL;
     qemuProcessPtr proc = NULL;
 
+    VIR_DEBUG("exec=%s, libDir=%s, runUid=%u, runGid=%u, forceTCG=%d",
+              NULLSTR(binary), NULLSTR(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->forceTCG = forceTCG;
 
     proc->runUid = runUid;
     proc->runGid = runGid;
 
-    return proc;
+    VIR_STEAL_PTR(ret, proc);
 
- error:
+ cleanup:
     qemuProcessFree(proc);
-    return NULL;
+    return ret;
 }
 
 
-- 
2.17.1

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