[PATCH] qemu: support qmp on RHEL/CentOS qemu

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

 



I'm getting tired of remembering to backport RHEL-specific
patches when building upstream libvirt on RHEL 6.x or CentOS.
All the affected versions of RHEL qemu-kvm have backported
enough patches to a) make JSON useful, and b) modify the
-help text to mention libvirt as the preferred interface;
which means this string in the help output is a reliable
indicator that we can outsmart a strict version check,
even when upstream qemu 0.12 lacked the needed features.

* src/qemu/qemu_capabilities.c (qemuCapsComputeCmdFlags):
Recognize particular help string present when enough features were
backported to be worth using JSON.
* tests/qemuhelptest.c (mymain): Update tests accordingly.
---
 src/qemu/qemu_capabilities.c |   17 +++++++++++++----
 tests/qemuhelptest.c         |    6 ++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 54757fc..c4bad6f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1104,7 +1104,8 @@ qemuCapsComputeCmdFlags(const char *help,
     if (strstr(help, "-netdev")) {
         /* Disable -netdev on 0.12 since although it exists,
          * the corresponding netdev_add/remove monitor commands
-         * do not, and we need them to be able todo hotplug */
+         * do not, and we need them to be able to do hotplug.
+         * But see below about RHEL build. */
         if (version >= 13000)
             qemuCapsSet(flags, QEMU_CAPS_NETDEV);
     }
@@ -1169,12 +1170,20 @@ qemuCapsComputeCmdFlags(const char *help,
     /* While JSON mode was available in 0.12.0, it was too
      * incomplete to contemplate using. The 0.13.0 release
      * is good enough to use, even though it lacks one or
-     * two features. The benefits of JSON mode now outweigh
-     * the downside.
+     * two features. This is also true of versions of qemu
+     * built for RHEL, labeled 0.12.1, but with extra text
+     * in the help output that mentions that features were
+     * backported for libvirt. The benefits of JSON mode now
+     * outweigh the downside.
      */
 #if HAVE_YAJL
-     if (version >= 13000)
+    if (version >= 13000) {
         qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
+    } else if (version >= 12000 &&
+               strstr(help, "libvirt")) {
+        qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
+        qemuCapsSet(flags, QEMU_CAPS_NETDEV);
+    }
 #endif

     if (version >= 13000)
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 8802271..5ad55bc 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -354,9 +354,11 @@ mymain(void)
             QEMU_CAPS_MIGRATE_QEMU_UNIX,
             QEMU_CAPS_CHARDEV,
             QEMU_CAPS_ENABLE_KVM,
+            QEMU_CAPS_MONITOR_JSON,
             QEMU_CAPS_BALLOON,
             QEMU_CAPS_DEVICE,
             QEMU_CAPS_SMP_TOPOLOGY,
+            QEMU_CAPS_NETDEV,
             QEMU_CAPS_RTC,
             QEMU_CAPS_VHOST_NET,
             QEMU_CAPS_NO_KVM_PIT,
@@ -503,9 +505,11 @@ mymain(void)
             QEMU_CAPS_MIGRATE_QEMU_UNIX,
             QEMU_CAPS_CHARDEV,
             QEMU_CAPS_ENABLE_KVM,
+            QEMU_CAPS_MONITOR_JSON,
             QEMU_CAPS_BALLOON,
             QEMU_CAPS_DEVICE,
             QEMU_CAPS_SMP_TOPOLOGY,
+            QEMU_CAPS_NETDEV,
             QEMU_CAPS_RTC,
             QEMU_CAPS_VHOST_NET,
             QEMU_CAPS_NO_KVM_PIT,
@@ -559,8 +563,10 @@ mymain(void)
             QEMU_CAPS_CHARDEV,
             QEMU_CAPS_ENABLE_KVM,
             QEMU_CAPS_BALLOON,
+            QEMU_CAPS_MONITOR_JSON,
             QEMU_CAPS_DEVICE,
             QEMU_CAPS_SMP_TOPOLOGY,
+            QEMU_CAPS_NETDEV,
             QEMU_CAPS_RTC,
             QEMU_CAPS_VHOST_NET,
             QEMU_CAPS_NO_KVM_PIT,
-- 
1.7.7.6

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