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

[libvirt] [PATCH v4 11/37] qemu_process: Use qemuProcess struct for a single process



In new process code, move from model where qemuProcess struct can be
used to activate a series of Qemu processes to model where one
qemuProcess struct is used for one and only one Qemu process.

The forceTCG parameter (use / don't use KVM) will be passed when the
qemuProcess struct is initialized since the qemuProcess struct won't be
reused.

Signed-off-by: Chris Venteicher <cventeic redhat com>
---
 src/qemu/qemu_capabilities.c | 16 ++++++++++++----
 src/qemu/qemu_process.c      | 11 +++++++----
 src/qemu/qemu_process.h      |  6 ++++--
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 359b6fbb9b..99a963912c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4275,14 +4275,16 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
                    char **qmperr)
 {
     qemuProcessPtr proc = NULL;
+    qemuProcessPtr proc_kvm = NULL;
     int ret = -1;
     int rc;
+    bool forceTCG = false;
 
     if (!(proc = qemuProcessNew(qemuCaps->binary, libDir,
-                                runUid, runGid, qmperr)))
+                                runUid, runGid, qmperr, forceTCG)))
         goto cleanup;
 
-    if ((rc = qemuProcessRun(proc, false)) != 0) {
+    if ((rc = qemuProcessRun(proc)) != 0) {
         if (rc == 1)
             ret = 0;
         goto cleanup;
@@ -4293,13 +4295,17 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
 
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
         qemuProcessStopQmp(proc);
-        if ((rc = qemuProcessRun(proc, true)) != 0) {
+
+        forceTCG = true;
+        proc_kvm = qemuProcessNew(qemuCaps->binary, libDir, runUid, runGid, NULL, forceTCG);
+
+        if ((rc = qemuProcessRun(proc_kvm)) != 0) {
             if (rc == 1)
                 ret = 0;
             goto cleanup;
         }
 
-        if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon) < 0)
+        if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc_kvm->mon) < 0)
             goto cleanup;
     }
 
@@ -4307,7 +4313,9 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
 
  cleanup:
     qemuProcessStopQmp(proc);
+    qemuProcessStopQmp(proc_kvm);
     qemuProcessFree(proc);
+    qemuProcessFree(proc_kvm);
     return ret;
 }
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 70d73cd457..d017efad84 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8097,7 +8097,8 @@ qemuProcessNew(const char *binary,
                const char *libDir,
                uid_t runUid,
                gid_t runGid,
-               char **qmperr)
+               char **qmperr,
+               bool forceTCG)
 {
     qemuProcessPtr proc = NULL;
 
@@ -8107,10 +8108,13 @@ qemuProcessNew(const char *binary,
     if (VIR_STRDUP(proc->binary, binary) < 0)
         goto error;
 
+    proc->forceTCG = forceTCG;
+
     proc->runUid = runUid;
     proc->runGid = runGid;
     proc->qmperr = qmperr;
 
+
     /* the ".sock" sufix is important to avoid a possible clash with a qemu
      * domain called "capabilities"
      */
@@ -8148,15 +8152,14 @@ qemuProcessNew(const char *binary,
  *          1 when probing QEMU failed
  */
 int
-qemuProcessRun(qemuProcessPtr proc,
-               bool forceTCG)
+qemuProcessRun(qemuProcessPtr proc)
 {
     virDomainXMLOptionPtr xmlopt = NULL;
     const char *machine;
     int status = 0;
     int ret = -1;
 
-    if (forceTCG)
+    if (proc->forceTCG)
         machine = "none,accel=tcg";
     else
         machine = "none,accel=kvm:tcg";
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 25343c4592..ab2640ce7c 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -229,17 +229,19 @@ struct _qemuProcess {
     virDomainChrSourceDef config;
     pid_t pid;
     virDomainObjPtr vm;
+    bool forceTCG;
 };
 
 qemuProcessPtr qemuProcessNew(const char *binary,
                               const char *libDir,
                               uid_t runUid,
                               gid_t runGid,
-                              char **qmperr);
+                              char **qmperr,
+                              bool forceTCG);
 
 void qemuProcessFree(qemuProcessPtr proc);
 
-int qemuProcessRun(qemuProcessPtr proc, bool forceTCG);
+int qemuProcessRun(qemuProcessPtr proc);
 
 void qemuProcessStopQmp(qemuProcessPtr proc);
 
-- 
2.17.1


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