[libvirt] [PATCH 15/20] qemu_process: Setup paths within qemuProcessQMPInit

Jiri Denemark posted 20 patches 6 years, 11 months ago
[libvirt] [PATCH 15/20] qemu_process: Setup paths within qemuProcessQMPInit
Posted by Jiri Denemark 6 years, 11 months ago
From: Chris Venteicher <cventeic@redhat.com>

Move code for setting paths and prepping file system from
qemuProcessQMPNew to qemuProcessQMPInit.

This keeps qemuProcessQMPNew limited to data structures and path
initialization is done in qemuProcessQMPInit.

The patch is a non-functional, cut / paste change, however goto is now
"cleanup" rather than "error".

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---

Notes:
    Version 7:
    - no change

 src/qemu/qemu_process.c | 42 +++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c4cbd7c807..9341aa43a7 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8361,26 +8361,6 @@ qemuProcessQMPNew(const char *binary,
     proc->runGid = runGid;
     proc->forceTCG = forceTCG;
 
-    /* the ".sock" sufix is important to avoid a possible clash with a qemu
-     * domain called "capabilities"
-     */
-    if (virAsprintf(&proc->monpath, "%s/%s", proc->libDir,
-                    "capabilities.monitor.sock") < 0)
-        goto error;
-    if (virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath) < 0)
-        goto error;
-
-    /* ".pidfile" suffix is used rather than ".pid" to avoid a possible clash
-     * with a qemu domain called "capabilities"
-     * Normally we'd use runDir for pid files, but because we're using
-     * -daemonize we need QEMU to be allowed to create them, rather
-     * than libvirtd. So we're using libDir which QEMU can write to
-     */
-    if (virAsprintf(&proc->pidfile, "%s/%s", proc->libDir, "capabilities.pidfile") < 0)
-        goto error;
-
-    virPidFileForceCleanupPath(proc->pidfile);
-
     return proc;
 
  error:
@@ -8396,8 +8376,30 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
 
     VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
 
+    /* the ".sock" sufix is important to avoid a possible clash with a qemu
+     * domain called "capabilities"
+     */
+    if (virAsprintf(&proc->monpath, "%s/%s", proc->libDir,
+                    "capabilities.monitor.sock") < 0)
+        goto cleanup;
+
+    if (virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath) < 0)
+        goto cleanup;
+
+    /* ".pidfile" suffix is used rather than ".pid" to avoid a possible clash
+     * with a qemu domain called "capabilities"
+     * Normally we'd use runDir for pid files, but because we're using
+     * -daemonize we need QEMU to be allowed to create them, rather
+     * than libvirtd. So we're using libDir which QEMU can write to
+     */
+    if (virAsprintf(&proc->pidfile, "%s/%s", proc->libDir, "capabilities.pidfile") < 0)
+        goto cleanup;
+
+    virPidFileForceCleanupPath(proc->pidfile);
+
     ret = 0;
 
+ cleanup:
     return ret;
 }
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 15/20] qemu_process: Setup paths within qemuProcessQMPInit
Posted by Ján Tomko 6 years, 11 months ago
On Tue, Feb 19, 2019 at 10:04:58AM +0100, Jiri Denemark wrote:
>From: Chris Venteicher <cventeic@redhat.com>
>
>Move code for setting paths and prepping file system from
>qemuProcessQMPNew to qemuProcessQMPInit.
>
>This keeps qemuProcessQMPNew limited to data structures and path
>initialization is done in qemuProcessQMPInit.
>
>The patch is a non-functional, cut / paste change, however goto is now
>"cleanup" rather than "error".
>
>Signed-off-by: Chris Venteicher <cventeic@redhat.com>
>Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
>Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
>---
>
>Notes:
>    Version 7:
>    - no change
>
> src/qemu/qemu_process.c | 42 +++++++++++++++++++++--------------------
> 1 file changed, 22 insertions(+), 20 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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