From nobody Wed May 14 12:34:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522278628691479.2098875927345; Wed, 28 Mar 2018 16:10:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5600680E4A; Wed, 28 Mar 2018 23:10:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D1DF5F723; Wed, 28 Mar 2018 23:10:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EB85A180BAD9; Wed, 28 Mar 2018 23:10:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2SNAACS023964 for ; Wed, 28 Mar 2018 19:10:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44A547C33; Wed, 28 Mar 2018 23:10:10 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFBEA8442B for ; Wed, 28 Mar 2018 23:10:07 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Thu, 29 Mar 2018 01:09:53 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/9] Introduce WITH_JSON X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Mar 2018 23:10:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 A library-agnostic constant used by all the code that requires a working virjson implementation, but does not depent on yajl. The only remaining usage outside virjson.c is the empty array test in virmacmaptest.c. Signed-off-by: J=C3=A1n Tomko --- m4/virt-json.m4 | 7 +++++++ src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_driver.c | 4 ++-- tests/Makefile.am | 10 +++++----- tests/cputest.c | 16 ++++++++-------- tests/libxlxml2domconfigtest.c | 4 ++-- tests/qemuagenttest.c | 2 +- tests/qemucapabilitiestest.c | 2 +- tests/qemucaps2xmltest.c | 2 +- tests/qemucommandutiltest.c | 2 +- tests/qemuhelptest.c | 2 +- tests/qemuhotplugtest.c | 2 +- tests/qemumonitorjsontest.c | 2 +- tests/virmocklibxl.c | 4 ++-- tests/virnetdaemontest.c | 2 +- tests/virstoragetest.c | 4 ++-- 16 files changed, 37 insertions(+), 30 deletions(-) diff --git a/m4/virt-json.m4 b/m4/virt-json.m4 index 1179ff5bb..2f2125b56 100644 --- a/m4/virt-json.m4 +++ b/m4/virt-json.m4 @@ -48,6 +48,13 @@ AC_DEFUN([LIBVIRT_CHECK_JSON],[ [yajl_parse_complete], [yajl/yajl_common.h], [YAJL2], [yajl], [yajl_tree_parse], [yajl/yajl_common.h]) + + AM_CONDITIONAL([WITH_JSON], + [test "$with_yajl" =3D "yes"]) + if test "$with_yajl" =3D "yes"; then + AC_DEFINE([WITH_JSON], [1], [whether a JSON library is available]) + fi + ]) =20 AC_DEFUN([LIBVIRT_RESULT_JSON],[ diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e54dde69a..3d8b83a41 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1385,7 +1385,7 @@ virQEMUCapsComputeCmdFlags(const char *help, * incomplete to contemplate using. The 0.13.0 release * is good enough to use, even though it lacks one or * two features. */ -#if WITH_YAJL +#if WITH_JSON if (version >=3D 13000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_MONITOR_JSON); #else diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7bcc4936d..ffda906f3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2122,7 +2122,7 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) */ if ((!useAgent) || (ret < 0 && (acpiRequested || !flags))) { -#if WITH_YAJL +#if WITH_JSON if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON)) { if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -2134,7 +2134,7 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("ACPI reboot is not supported without the JSO= N monitor")); goto endjob; -#if WITH_YAJL +#if WITH_JSON } #endif qemuDomainSetFakeReboot(driver, vm, isReboot); diff --git a/tests/Makefile.am b/tests/Makefile.am index 289ef35bd..249c533dc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -333,9 +333,9 @@ if WITH_CIL test_programs +=3D objectlocking endif WITH_CIL =20 -if WITH_YAJL +if WITH_JSON test_programs +=3D virjsontest -endif WITH_YAJL +endif WITH_JSON =20 test_programs +=3D \ networkxml2xmltest \ @@ -1233,15 +1233,15 @@ virdeterministichashmock_la_LIBADD =3D $(MOCKLIBS_L= IBS) =20 test_libraries +=3D virdeterministichashmock.la =20 -if WITH_YAJL +if WITH_JSON virmacmaptest_SOURCES =3D \ virmacmaptest.c testutils.h testutils.c virmacmaptest_LDADD =3D $(LDADDS) =20 test_programs +=3D virmacmaptest -else ! WITH_YAJL +else ! WITH_JSON EXTRA_DIST +=3D virmacmaptest.c -endif ! WITH_YAJL +endif ! WITH_JSON =20 virnetdevtest_SOURCES =3D \ virnetdevtest.c testutils.h testutils.c diff --git a/tests/cputest.c b/tests/cputest.c index 1e79edbef..ab1054266 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -40,7 +40,7 @@ #include "cpu/cpu_map.h" #include "virstring.h" =20 -#if WITH_QEMU && WITH_YAJL +#if WITH_QEMU && WITH_JSON # include "testutilsqemu.h" # include "qemumonitortestutils.h" # define __QEMU_CAPSPRIV_H_ALLOW__ @@ -67,7 +67,7 @@ struct data { int result; }; =20 -#if WITH_QEMU && WITH_YAJL +#if WITH_QEMU && WITH_JSON static virQEMUDriver driver; #endif =20 @@ -479,7 +479,7 @@ typedef enum { JSON_MODELS_REQUIRED, } cpuTestCPUIDJson; =20 -#if WITH_QEMU && WITH_YAJL +#if WITH_QEMU && WITH_JSON static virQEMUCapsPtr cpuTestMakeQEMUCaps(const struct data *data) { @@ -554,7 +554,7 @@ cpuTestGetCPUModels(const struct data *data, return 0; } =20 -#else /* if WITH_QEMU && WITH_YAJL */ +#else /* if WITH_QEMU && WITH_JSON */ =20 static int cpuTestGetCPUModels(const struct data *data, @@ -834,7 +834,7 @@ cpuTestUpdateLive(const void *arg) } =20 =20 -#if WITH_QEMU && WITH_YAJL +#if WITH_QEMU && WITH_JSON static int cpuTestJSONCPUID(const void *arg) { @@ -911,7 +911,7 @@ mymain(void) virDomainCapsCPUModelsPtr ppc_models =3D NULL; int ret =3D 0; =20 -#if WITH_QEMU && WITH_YAJL +#if WITH_QEMU && WITH_JSON if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; =20 @@ -1004,7 +1004,7 @@ mymain(void) host "/" cpu " (" #models ")", \ host, cpu, models, 0, result) =20 -#if WITH_QEMU && WITH_YAJL +#if WITH_QEMU && WITH_JSON # define DO_TEST_JSON(arch, host, json) \ do { \ if (json =3D=3D JSON_MODELS) { \ @@ -1204,7 +1204,7 @@ mymain(void) DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-X5460", JSON_NONE); =20 cleanup: -#if WITH_QEMU && WITH_YAJL +#if WITH_QEMU && WITH_JSON qemuTestDriverFree(&driver); #endif =20 diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 6eec4c752..cafdf8e02 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -33,7 +33,7 @@ =20 #include "testutils.h" =20 -#if defined(WITH_LIBXL) && defined(WITH_YAJL) && defined(HAVE_LIBXL_DOMAIN= _CONFIG_FROM_JSON) +#if defined(WITH_LIBXL) && defined(WITH_JSON) && defined(HAVE_LIBXL_DOMAIN= _CONFIG_FROM_JSON) =20 # include "internal.h" # include "viralloc.h" @@ -210,4 +210,4 @@ int main(void) return EXIT_AM_SKIP; } =20 -#endif /* WITH_LIBXL && WITH_YAJL && HAVE_LIBXL_DOMAIN_CONFIG_FROM_JSON */ +#endif /* WITH_LIBXL && WITH_JSON && HAVE_LIBXL_DOMAIN_CONFIG_FROM_JSON */ diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index f214eb461..0af46bc0d 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -907,7 +907,7 @@ mymain(void) { int ret =3D 0; =20 -#if !WITH_YAJL +#if !WITH_JSON fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index 0d136cc8b..7091d6093 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -139,7 +139,7 @@ mymain(void) virQEMUDriver driver; testQemuData data; =20 -#if !WITH_YAJL +#if !WITH_JSON fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index f4838f798..705b5c187 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -165,7 +165,7 @@ mymain(void) =20 testQemuData data; =20 -#if !WITH_YAJL +#if !WITH_JSON fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif diff --git a/tests/qemucommandutiltest.c b/tests/qemucommandutiltest.c index eb155e7e1..106f83969 100644 --- a/tests/qemucommandutiltest.c +++ b/tests/qemucommandutiltest.c @@ -76,7 +76,7 @@ mymain(void) int ret =3D 0; testQemuCommandBuildObjectFromJSONData data1; =20 -#if !WITH_YAJL +#if !WITH_JSON fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 1336eeef5..c21f24cec 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -67,7 +67,7 @@ static int testHelpStrParsing(const void *data) goto cleanup; } =20 -# ifndef WITH_YAJL +# ifndef WITH_JSON if (virQEMUCapsGet(info->flags, QEMU_CAPS_MONITOR_JSON)) virQEMUCapsSet(flags, QEMU_CAPS_MONITOR_JSON); # endif diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 85e53653e..18809adcb 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -588,7 +588,7 @@ mymain(void) struct qemuHotplugTestData data =3D {0}; struct testQemuHotplugCpuParams cpudata; =20 -#if !WITH_YAJL +#if !WITH_JSON fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 0afdc8003..6829236b7 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2886,7 +2886,7 @@ mymain(void) struct testQAPISchemaData qapiData; char *metaschema =3D NULL; =20 -#if !WITH_YAJL +#if !WITH_JSON fputs("libvirt not compiled with yajl, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif diff --git a/tests/virmocklibxl.c b/tests/virmocklibxl.c index 973595659..8429cbb6b 100644 --- a/tests/virmocklibxl.c +++ b/tests/virmocklibxl.c @@ -22,7 +22,7 @@ =20 #include =20 -#if defined(WITH_LIBXL) && defined(WITH_YAJL) +#if defined(WITH_LIBXL) && defined(WITH_JSON) # include "virmock.h" # include # include @@ -104,4 +104,4 @@ VIR_MOCK_IMPL_RET_ARGS(stat, int, return real_stat(path, sb); } =20 -#endif /* WITH_LIBXL && WITH_YAJL */ +#endif /* WITH_LIBXL && WITH_JSON */ diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c index ef869b16e..e42e349aa 100644 --- a/tests/virnetdaemontest.c +++ b/tests/virnetdaemontest.c @@ -26,7 +26,7 @@ =20 #define VIR_FROM_THIS VIR_FROM_RPC =20 -#if defined(HAVE_SOCKETPAIR) && defined(WITH_YAJL) +#if defined(HAVE_SOCKETPAIR) && defined(WITH_JSON) struct testClientPriv { int magic; }; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index b032d8b93..99cf3bd25 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1364,7 +1364,7 @@ mymain(void) " \n" "\n"); =20 -#ifdef WITH_YAJL +#ifdef WITH_JSON TEST_BACKING_PARSE("json:", NULL); TEST_BACKING_PARSE("json:asdgsdfg", NULL); TEST_BACKING_PARSE("json:{}", NULL); @@ -1628,7 +1628,7 @@ mymain(void) "\n" " \n" "\n"); -#endif /* WITH_YAJL */ +#endif /* WITH_JSON */ =20 cleanup: /* Final cleanup */ --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list