[PATCH RFC 07/22] qemu_process: Use qemuProcess struct for a single process

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

 



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@xxxxxxxxxx>
---
 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 082874082b..a957c3bdbd 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4220,14 +4220,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;
@@ -4238,13 +4240,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;
     }
 
@@ -4252,7 +4258,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 2571024e8e..dda74d5b7a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8100,7 +8100,8 @@ qemuProcessNew(const char *binary,
                const char *libDir,
                uid_t runUid,
                gid_t runGid,
-               char **qmperr)
+               char **qmperr,
+               bool forceTCG)
 {
     qemuProcessPtr proc = NULL;
 
@@ -8110,10 +8111,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"
      */
@@ -8151,15 +8155,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

--
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