]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: support qmp on RHEL/CentOS qemu
authorEric Blake <eblake@redhat.com>
Thu, 26 Jan 2012 04:33:21 +0000 (21:33 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 27 Jan 2012 15:11:19 +0000 (08:11 -0700)
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
tests/qemuhelptest.c

index 54757fcd26b3dc1cfc7e6af3b182738bf59a2e22..c4bad6f02eaa697881d895c44109274d79dc0b02 100644 (file)
@@ -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)
index 8802271d394c02fb83666e9757af0a45d8fe79cd..5ad55bc730b2a216d8b5c776d5249aa01ded617e 100644 (file)
@@ -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,