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(a)redhat.com>
---
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