]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: simplify use of HAVE_YAJL
authorEric Blake <eblake@redhat.com>
Thu, 20 Oct 2011 20:36:32 +0000 (14:36 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 26 Oct 2011 17:55:39 +0000 (11:55 -0600)
Rather than making all clients of monitor commands that are JSON-only
check whether yajl support was compiled in, it is simpler to just
avoid setting the capability bit up front if we can't use the capability.

* src/qemu/qemu_capabilities.c (qemuCapsComputeCmdFlags): Only set
capability bit if we also have yajl library to use it.
* src/qemu/qemu_driver.c (qemuDomainReboot): Drop #ifdefs.
* src/qemu/qemu_process.c (qemuProcessStart): Likewise.
* tests/qemuhelptest.c (testHelpStrParsing): Pass test even
without yajl.
* tests/qemuxml2argvtest.c (mymain): Simplify use of json flag.
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-*.args:
Update expected results to match.

src/qemu/qemu_capabilities.c
src/qemu/qemu_driver.c
src/qemu/qemu_process.c
tests/qemuhelptest.c
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args
tests/qemuxml2argvtest.c

index 5f0356c518662517c264b535c48cc4d64d078fe4..b4ab55bf7cc53bd5b60bf25239bd9610126d5a2e 100644 (file)
@@ -1060,8 +1060,10 @@ qemuCapsComputeCmdFlags(const char *help,
      * two features. The benefits of JSON mode now outweigh
      * the downside.
      */
+#if HAVE_YAJL
      if (version >= 13000)
         qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
+#endif
 
     if (version >= 13000)
         qemuCapsSet(flags, QEMU_CAPS_PCI_MULTIFUNCTION);
index f93b78487391e32cc6972e0d7c8e35b1c433b354..e053a97457e9380e67cde2702b42968efd0f8cb7 100644 (file)
@@ -1545,9 +1545,7 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
     struct qemud_driver *driver = dom->conn->privateData;
     virDomainObjPtr vm;
     int ret = -1;
-#if HAVE_YAJL
     qemuDomainObjPrivatePtr priv;
-#endif
 
     virCheckFlags(0, -1);
 
@@ -1563,7 +1561,6 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
         goto cleanup;
     }
 
-#if HAVE_YAJL
     priv = vm->privateData;
 
     if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON)) {
@@ -1593,12 +1590,9 @@ static int qemuDomainReboot(virDomainPtr dom, unsigned int flags) {
         if (qemuDomainObjEndJob(driver, vm) == 0)
             vm = NULL;
     } else {
-#endif
         qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
                         _("Reboot is not supported without the JSON monitor"));
-#if HAVE_YAJL
     }
-#endif
 
 cleanup:
     if (vm)
index 18c98c6f01054e36eb44c41ece33462f6ad41aca..47164f7b476845be871a637e20fd3a2abbc63156 100644 (file)
@@ -2969,11 +2969,9 @@ int qemuProcessStart(virConnectPtr conn,
     if (qemuProcessPrepareMonitorChr(driver, priv->monConfig, vm->def->name) < 0)
         goto cleanup;
 
-#if HAVE_YAJL
     if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON))
         priv->monJSON = 1;
     else
-#endif
         priv->monJSON = 0;
 
     priv->monError = false;
index fcee41fff91e60a27694ae6a3bc2958cfa9d5f64..df677cc5eedcc743d0967ebcde93f3e740955842 100644 (file)
@@ -56,6 +56,11 @@ static int testHelpStrParsing(const void *data)
                              &version, &is_kvm, &kvm_version) == -1)
         goto cleanup;
 
+# ifndef HAVE_YAJL
+    if (qemuCapsGet(info->flags, QEMU_CAPS_MONITOR_JSON))
+        qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
+# endif
+
     if (qemuCapsGet(info->flags, QEMU_CAPS_DEVICE)) {
         VIR_FREE(path);
         VIR_FREE(help);
index 981d410431f58e81bb891364b8518c66b57a5a6b..0fc6ccc71b54e203024d532efaa2c3088e479370 100644 (file)
@@ -1,5 +1,6 @@
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
-pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+pc -m 214 -smp 1 -nographic \
+-monitor control,unix:/tmp/test-monitor,server,nowait \
 -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,\
 format=qcow2,cache=off,werror=enospc -drive \
 file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,bus=1,unit=0,format=raw -net \
index 877c0db4f7fd122ea9c44ea4099970af5c17dc7d..bf955a95a6bb464bce8b6218fa3f6ed3ea6da216 100644 (file)
@@ -1,5 +1,6 @@
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
-pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+pc -m 214 -smp 1 -nographic \
+-monitor control,unix:/tmp/test-monitor,server,nowait \
 -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,\
 format=qcow2,cache=off,werror=stop,rerror=stop -drive \
 file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,bus=1,unit=0,format=raw -net \
index 48795760f5d1b6681417c935f759db274b72a582..6bb9a930cd2c40c809c879cdca37c5e45edeec7d 100644 (file)
@@ -1,5 +1,6 @@
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
-pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+pc -m 214 -smp 1 -nographic \
+-monitor control,unix:/tmp/test-monitor,server,nowait \
 -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,\
 format=qcow2,cache=off,werror=report,rerror=ignore -drive \
 file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,bus=1,unit=0,format=raw -net \
index a64f45e69ce8c6486673486d96a0f4a774766277..4d6db01925f718b2d96fe679e2ce6213ec7d48ed 100644 (file)
@@ -174,7 +174,6 @@ struct testInfo {
     virBitmapPtr extraFlags;
     const char *migrateFrom;
     int migrateFd;
-    bool json;
     bool expectError;
 };
 
@@ -194,7 +193,9 @@ testCompareXMLToArgvHelper(const void *data)
 
     result = testCompareXMLToArgvFiles(xml, args, info->extraFlags,
                                        info->migrateFrom, info->migrateFd,
-                                       info->json, info->expectError);
+                                       qemuCapsGet(info->extraFlags,
+                                                   QEMU_CAPS_MONITOR_JSON),
+                                       info->expectError);
 
 cleanup:
     free(xml);
@@ -209,7 +210,6 @@ mymain(void)
 {
     int ret = 0;
     char *map = NULL;
-    bool json = false;
 
     abs_top_srcdir = getenv("abs_top_srcdir");
     if (!abs_top_srcdir)
@@ -237,7 +237,7 @@ mymain(void)
 # define DO_TEST_FULL(name, migrateFrom, migrateFd, expectError, ...)   \
     do {                                                                \
         struct testInfo info = {                                        \
-            name, NULL, migrateFrom, migrateFd, json, expectError       \
+            name, NULL, migrateFrom, migrateFd, expectError             \
         };                                                              \
         if (!(info.extraFlags = qemuCapsNew()))                         \
             return EXIT_FAILURE;                                        \
@@ -588,13 +588,11 @@ mymain(void)
             QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_PCI_MULTIFUNCTION);
 
-    json = true;
     DO_TEST("monitor-json", false, QEMU_CAPS_DEVICE,
             QEMU_CAPS_CHARDEV, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_NODEFCONFIG);
     DO_TEST("no-shutdown", false, QEMU_CAPS_DEVICE,
             QEMU_CAPS_CHARDEV, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_NO_SHUTDOWN);
-    json = false;
 
     free(driver.stateDir);
     virCapabilitiesFree(driver.caps);