[PATCH 2/2 v2] qemu: Fix SW emulated machines

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

 



This patch fixes building a command-line for QEMU machines without KVM
acceleration and is based on following assumptions:

 - QEMU_CAPS_KVM flag means that QEMU is capable of running KVM
   accelerated machine (not that it knows about KVM at all, even
   though there is probably no QEMU that knows about KVM and isn't
   able to use it).  It is not actually true for the past (it meant
   that QEMU has '-no-kvm' option, that it doesn't always know), but
   we can say this is what it means from now on without any harm being
   done.

 - QEMU_CAPS_ENABLE_KVM flag means that QEMU is, by default, running
   without KVM acceleration and in case we need KVM acceleration it
   needs to be explicitely instructed to do so.  This is partially
   true for the past (this option essentially means that QEMU
   recognizes the '-enable-kvm' option, even though it's almost the
   same).
---
 src/qemu/qemu_capabilities.c | 16 ++++++++++++----
 src/qemu/qemu_command.c      |  6 ++++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index fe462e9..a19d833 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2039,9 +2039,18 @@ qemuCapsProbeQMPKVMState(qemuCapsPtr caps,
     if (qemuMonitorGetKVMState(mon, &enabled, &present) < 0)
         return -1;

-    /* Youre right, this code does nothing, you must have checked out
-     * some weird commit.  Go back to your room and think about what
-     * you've done, young (wo)man. */
+    if (!present) {
+        /* When KVM is not present, the flag shouldn't be set, but it
+         * was set earlier when we discovered that QEMU is capable of
+         * "query-kvm" QMP command (which doesn't mean anything,
+         * essentially).  So let's fix that. */
+        qemuCapsClear(caps, QEMU_CAPS_KVM);
+    } else if (!enabled) {
+        /* We shouldn't use -enable-kvm when kvm is enabled by
+         * default, but more importantly, we should be able to know
+         * when not using it launches a software emulated machine. */
+        qemuCapsSet(caps, QEMU_CAPS_ENABLE_KVM);
+    }

     return 0;
 }
@@ -2177,7 +2186,6 @@ qemuCapsInitQMPBasic(qemuCapsPtr caps)
     qemuCapsSet(caps, QEMU_CAPS_DRIVE_SERIAL);
     qemuCapsSet(caps, QEMU_CAPS_MIGRATE_QEMU_UNIX);
     qemuCapsSet(caps, QEMU_CAPS_CHARDEV);
-    qemuCapsSet(caps, QEMU_CAPS_ENABLE_KVM);
     qemuCapsSet(caps, QEMU_CAPS_MONITOR_JSON);
     qemuCapsSet(caps, QEMU_CAPS_BALLOON);
     qemuCapsSet(caps, QEMU_CAPS_DEVICE);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 898c4c0..2f863d3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4466,12 +4466,14 @@ qemuBuildCommandLine(virConnectPtr conn,
     case VIR_DOMAIN_VIRT_QEMU:
         if (qemuCapsGet(caps, QEMU_CAPS_KQEMU))
             disableKQEMU = 1;
-        if (qemuCapsGet(caps, QEMU_CAPS_KVM))
+        if (qemuCapsGet(caps, QEMU_CAPS_KVM) &&
+            !qemuCapsGet(caps, QEMU_CAPS_ENABLE_KVM))
             disableKVM = 1;
         break;

     case VIR_DOMAIN_VIRT_KQEMU:
-        if (qemuCapsGet(caps, QEMU_CAPS_KVM))
+        if (qemuCapsGet(caps, QEMU_CAPS_KVM) &&
+            !qemuCapsGet(caps, QEMU_CAPS_ENABLE_KVM))
             disableKVM = 1;

         if (qemuCapsGet(caps, QEMU_CAPS_ENABLE_KQEMU)) {
--
1.7.12.4

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