[PATCH v6 12/33] qemu_process: Collect monitor code in single function

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

 



qemuMonitor code lives in qemuProcessQMPConnectMonitor rather than in
qemuProcessQMPNew and qemuProcessQMPLaunch.

This is consistent with existing structure in qemu_process.c where
qemuConnectMonitor function contains monitor code for domain process
activation.

Simple code moves in this patch.  Improvements in later patch.

Only intended functional change in this patch is we don't
move (include) code to initiate process stop on failure to create monitor.

As comments in qemuProcessQMPStart say... Client must always call
qemuProcessStop and qemuProcessQMPFree, even in error cases.

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

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 3b785d64e5..5492ff5a19 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8258,10 +8258,6 @@ qemuProcessQMPNew(const char *binary,
 
     virPidFileForceCleanupPath(proc->pidfile);
 
-    proc->config.type = VIR_DOMAIN_CHR_TYPE_UNIX;
-    proc->config.data.nix.path = proc->monpath;
-    proc->config.data.nix.listen = false;
-
     return proc;
 
  error:
@@ -8292,7 +8288,6 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
 static int
 qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
 {
-    virDomainXMLOptionPtr xmlopt = NULL;
     const char *machine;
     int ret = -1;
 
@@ -8344,6 +8339,28 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
         goto cleanup;
     }
 
+    ret = 0;
+
+ cleanup:
+    return ret;
+}
+
+
+/* Connect Monitor to QEMU Process
+ */
+static int
+qemuProcessQMPConnectMonitor(qemuProcessQMPPtr proc)
+{
+    int ret = -1;
+    virDomainXMLOptionPtr xmlopt = NULL;
+
+    VIR_DEBUG("proc=%p, emulator=%s, proc->pid=%lld",
+              proc, proc->binary, (long long)proc->pid);
+
+    proc->config.type = VIR_DOMAIN_CHR_TYPE_UNIX;
+    proc->config.data.nix.path = proc->monpath;
+    proc->config.data.nix.listen = false;
+
     if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
         !(proc->vm = virDomainObjNew(xmlopt)))
         goto cleanup;
@@ -8359,27 +8376,8 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
     ret = 0;
 
  cleanup:
-    if (!proc->mon)
-        qemuProcessQMPStop(proc);
+    VIR_DEBUG("ret=%i", ret);
     virObjectUnref(xmlopt);
-
-    return ret;
-}
-
-
-/* Connect Monitor to QEMU Process
- */
-static int
-qemuProcessQMPConnectMonitor(qemuProcessQMPPtr proc)
-{
-    int ret = -1;
-
-    VIR_DEBUG("proc=%p, emulator=%s, proc->pid=%lld",
-              proc, proc->binary, (long long)proc->pid);
-
-    ret = 0;
-
-    VIR_DEBUG("ret=%i", ret);
     return ret;
 }
 
-- 
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