From: Chris Venteicher <cventeic(a)redhat.com>
This is a replacement for qemuProcessQMPRun to make the name consistent
with qemuProcessStart. The original qemuProcessQMPRun function is
renamed as qemuProcessQMPLaunch and becomes one of the simpler functions
called from the main qemuProcessQMPStart entry point. The following
patches will move parts of the code in qemuProcessQMPLaunch to the other
functions (qemuProcessQMPInit and qemuProcessQMPConnectMonitor).
Signed-off-by: Chris Venteicher <cventeic(a)redhat.com>
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Notes:
Version 7:
- removed some fairy tales from the commit message and the documentation
of qemuProcessQMPStart
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_process.c | 74 +++++++++++++++++++++++++++++++++++-
src/qemu/qemu_process.h | 2 +-
3 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7460b452a0..4fd2169d49 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4385,7 +4385,7 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps,
runUid, runGid, onlyTCG)))
goto cleanup;
- if (qemuProcessQMPRun(proc) < 0)
+ if (qemuProcessQMPStart(proc) < 0)
goto cleanup;
if (onlyTCG)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d2859da2ec..19bc804d18 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8391,8 +8391,21 @@ qemuProcessQMPNew(const char *binary,
}
-int
-qemuProcessQMPRun(qemuProcessQMPPtr proc)
+static int
+qemuProcessQMPInit(qemuProcessQMPPtr proc)
+{
+ int ret = -1;
+
+ VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
+
+ ret = 0;
+
+ return ret;
+}
+
+
+static int
+qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
{
virDomainXMLOptionPtr xmlopt = NULL;
const char *machine;
@@ -8480,6 +8493,63 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
}
+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;
+
+ return ret;
+}
+
+
+/**
+ * qemuProcessQMPStart:
+ * @proc: QEMU process and connection state created by qemuProcessQMPNew()
+ *
+ * Start and connect to QEMU binary so QMP queries can be made.
+ *
+ * Usage:
+ * proc = qemuProcessQMPNew(binary, libDir, runUid, runGid, forceTCG);
+ * qemuProcessQMPStart(proc);
+ * ** Send QMP Queries to QEMU using monitor (proc->mon) **
+ * qemuProcessQMPStop(proc);
+ * qemuProcessQMPFree(proc);
+ *
+ * Process error output (proc->stderr) remains available in qemuProcessQMP
+ * struct until qemuProcessQMPFree is called.
+ */
+int
+qemuProcessQMPStart(qemuProcessQMPPtr proc)
+{
+ int ret = -1;
+
+ VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
+
+ if (qemuProcessQMPInit(proc) < 0)
+ goto cleanup;
+
+ if (qemuProcessQMPLaunch(proc) < 0)
+ goto stop;
+
+ if (qemuProcessQMPConnectMonitor(proc) < 0)
+ goto stop;
+
+ ret = 0;
+
+ cleanup:
+ return ret;
+
+ stop:
+ qemuProcessQMPStop(proc);
+ goto cleanup;
+}
+
+
void
qemuProcessQMPStop(qemuProcessQMPPtr proc)
{
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index e7d4ca0c92..c075ae6445 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -240,7 +240,7 @@ qemuProcessQMPPtr qemuProcessQMPNew(const char *binary,
void qemuProcessQMPFree(qemuProcessQMPPtr proc);
-int qemuProcessQMPRun(qemuProcessQMPPtr proc);
+int qemuProcessQMPStart(qemuProcessQMPPtr proc);
void qemuProcessQMPStop(qemuProcessQMPPtr proc);
--
2.20.1