]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_process: Introduce qemuProcessQMPStart
authorChris Venteicher <cventeic@redhat.com>
Sun, 13 Jan 2019 00:50:10 +0000 (18:50 -0600)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 19 Feb 2019 17:43:49 +0000 (18:43 +0100)
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@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_capabilities.c
src/qemu/qemu_process.c
src/qemu/qemu_process.h

index 7460b452a05d61e71789aa9f682f77e4df4f6154..4fd2169d493016558eadc15489f5d1040040e35c 100644 (file)
@@ -4385,7 +4385,7 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps,
                                    runUid, runGid, onlyTCG)))
         goto cleanup;
 
-    if (qemuProcessQMPRun(proc) < 0)
+    if (qemuProcessQMPStart(proc) < 0)
         goto cleanup;
 
     if (onlyTCG)
index d2859da2ec9ea6b20ac004c5e8c131e656f57bac..19bc804d1820b6576144921b9f785f2ed9be8fd9 100644 (file)
@@ -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)
 {
index e7d4ca0c92f7b5ab0314fc97a89274036b793bf6..c075ae64457e89f59fac3dea6a68dc87f92a84ed 100644 (file)
@@ -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);