]> TLD Linux GIT Repositories - packages/libvirt.git/blob - yajl.patch
- release 3
[packages/libvirt.git] / yajl.patch
1 diff -urNpa libvirt-4.6.0.orig/config-post.h libvirt-4.6.0/config-post.h
2 --- libvirt-4.6.0.orig/config-post.h    2018-07-28 13:26:44.376463865 +0000
3 +++ libvirt-4.6.0/config-post.h 2018-08-20 18:00:20.571398013 +0000
4 @@ -36,7 +36,6 @@
5  # undef WITH_DEVMAPPER
6  # undef WITH_DTRACE_PROBES
7  # undef WITH_GNUTLS
8 -# undef WITH_JANSSON
9  # undef WITH_LIBSSH
10  # undef WITH_MACVTAP
11  # undef WITH_NUMACTL
12 @@ -44,6 +43,8 @@
13  # undef WITH_SSH2
14  # undef WITH_SYSTEMD_DAEMON
15  # undef WITH_VIRTUALPORT
16 +# undef WITH_YAJL
17 +# undef WITH_YAJL2
18  #endif
19  
20  /*
21 diff -urNpa libvirt-4.6.0.orig/configure.ac libvirt-4.6.0/configure.ac
22 --- libvirt-4.6.0.orig/configure.ac     2018-07-28 13:26:44.376463865 +0000
23 +++ libvirt-4.6.0/configure.ac  2018-08-20 18:01:24.611397292 +0000
24 @@ -250,7 +250,6 @@ LIBVIRT_ARG_FIREWALLD
25  LIBVIRT_ARG_FUSE
26  LIBVIRT_ARG_GLUSTER
27  LIBVIRT_ARG_HAL
28 -LIBVIRT_ARG_JANSSON
29  LIBVIRT_ARG_LIBPCAP
30  LIBVIRT_ARG_LIBSSH
31  LIBVIRT_ARG_LIBXML
32 @@ -291,7 +290,6 @@ LIBVIRT_CHECK_FUSE
33  LIBVIRT_CHECK_GLUSTER
34  LIBVIRT_CHECK_GNUTLS
35  LIBVIRT_CHECK_HAL
36 -LIBVIRT_CHECK_JANSSON
37  LIBVIRT_CHECK_LIBNL
38  LIBVIRT_CHECK_LIBPARTED
39  LIBVIRT_CHECK_LIBPCAP
40 @@ -972,7 +970,6 @@ LIBVIRT_RESULT_FUSE
41  LIBVIRT_RESULT_GLUSTER
42  LIBVIRT_RESULT_GNUTLS
43  LIBVIRT_RESULT_HAL
44 -LIBVIRT_RESULT_JANSSON
45  LIBVIRT_RESULT_LIBNL
46  LIBVIRT_RESULT_LIBPCAP
47  LIBVIRT_RESULT_LIBSSH
48 diff -urNpa libvirt-4.6.0.orig/libvirt.spec.in libvirt-4.6.0/libvirt.spec.in
49 --- libvirt-4.6.0.orig/libvirt.spec.in  2018-08-02 03:58:35.025820949 +0000
50 +++ libvirt-4.6.0/libvirt.spec.in       2018-08-20 18:00:20.572398013 +0000
51 @@ -292,7 +292,7 @@ BuildRequires: libblkid-devel >= 2.17
52  BuildRequires: augeas
53  BuildRequires: systemd-devel >= 185
54  BuildRequires: libpciaccess-devel >= 0.10.9
55 -BuildRequires: jansson-devel
56 +BuildRequires: yajl-devel
57  %if %{with_sanlock}
58  BuildRequires: sanlock-devel >= 2.4
59  %endif
60 @@ -898,8 +898,6 @@ Requires: ncurses
61  Requires: gettext
62  # Needed by virt-pki-validate script.
63  Requires: gnutls-utils
64 -# We dlopen(libjansson.so.4), so need an explicit dep
65 -Requires: jansson
66  %if %{with_bash_completion}
67  Requires: %{name}-bash-completion = %{version}-%{release}
68  %endif
69 @@ -1228,7 +1226,7 @@ rm -f po/stamp-po
70             --without-apparmor \
71             --without-hal \
72             --with-udev \
73 -           --with-jansson \
74 +           --with-yajl \
75             %{?arg_sanlock} \
76             --with-libpcap \
77             --with-macvtap \
78 diff -urNpa libvirt-4.6.0.orig/m4/virt-driver-qemu.m4 libvirt-4.6.0/m4/virt-driver-qemu.m4
79 --- libvirt-4.6.0.orig/m4/virt-driver-qemu.m4   2018-07-28 13:26:44.395463693 +0000
80 +++ libvirt-4.6.0/m4/virt-driver-qemu.m4        2018-08-20 18:00:20.572398013 +0000
81 @@ -18,7 +18,7 @@ dnl <http://www.gnu.org/licenses/>.
82  dnl
83  
84  AC_DEFUN([LIBVIRT_DRIVER_ARG_QEMU], [
85 -  LIBVIRT_ARG_WITH_FEATURE([QEMU], [QEMU/KVM], [check])
86 +  LIBVIRT_ARG_WITH_FEATURE([QEMU], [QEMU/KVM], [yes])
87    LIBVIRT_ARG_WITH([QEMU_USER], [username to run QEMU system instance as],
88                     ['platform dependent'])
89    LIBVIRT_ARG_WITH([QEMU_GROUP], [groupname to run QEMU system instance as],
90 @@ -26,13 +26,6 @@ AC_DEFUN([LIBVIRT_DRIVER_ARG_QEMU], [
91  ])
92  
93  AC_DEFUN([LIBVIRT_DRIVER_CHECK_QEMU], [
94 -  AC_REQUIRE([LIBVIRT_CHECK_JANSSON])
95 -  if test "$with_qemu:$with_jansson" = "yes:no"; then
96 -    AC_MSG_ERROR([Jansson >= 2.5 is required to build QEMU driver])
97 -  fi
98 -  if test "$with_qemu" = "check"; then
99 -    with_qemu=$with_jansson
100 -  fi
101    if test "$with_qemu" = "yes" ; then
102      AC_DEFINE_UNQUOTED([WITH_QEMU], 1, [whether QEMU driver is enabled])
103    fi
104 diff -urNpa libvirt-4.6.0.orig/m4/virt-jansson.m4 libvirt-4.6.0/m4/virt-jansson.m4
105 --- libvirt-4.6.0.orig/m4/virt-jansson.m4       2018-07-28 13:26:44.395463693 +0000
106 +++ libvirt-4.6.0/m4/virt-jansson.m4    1970-01-01 00:00:00.000000000 +0000
107 @@ -1,32 +0,0 @@
108 -dnl The jansson library
109 -dnl
110 -dnl This library is free software; you can redistribute it and/or
111 -dnl modify it under the terms of the GNU Lesser General Public
112 -dnl License as published by the Free Software Foundation; either
113 -dnl version 2.1 of the License, or (at your option) any later version.
114 -dnl
115 -dnl This library is distributed in the hope that it will be useful,
116 -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
117 -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
118 -dnl Lesser General Public License for more details.
119 -dnl
120 -dnl You should have received a copy of the GNU Lesser General Public
121 -dnl License along with this library.  If not, see
122 -dnl <http://www.gnu.org/licenses/>.
123 -dnl
124 -
125 -AC_DEFUN([LIBVIRT_ARG_JANSSON],[
126 -  LIBVIRT_ARG_WITH_FEATURE([JANSSON], [jansson], [check])
127 -])
128 -
129 -AC_DEFUN([LIBVIRT_CHECK_JANSSON],[
130 -  dnl Jansson http://www.digip.org/jansson/
131 -  LIBVIRT_CHECK_PKG([JANSSON], [jansson], [2.5])
132 -  dnl Older versions of Jansson did not preserve the order of object keys
133 -  dnl use this check to guard the tests that are sensitive to this
134 -  LIBVIRT_CHECK_PKG([STABLE_ORDERING_JANSSON], [jansson], [2.8], [true])
135 -])
136 -
137 -AC_DEFUN([LIBVIRT_RESULT_JANSSON],[
138 -  LIBVIRT_RESULT_LIB([JANSSON])
139 -])
140 diff -urNpa libvirt-4.6.0.orig/m4/virt-nss.m4 libvirt-4.6.0/m4/virt-nss.m4
141 --- libvirt-4.6.0.orig/m4/virt-nss.m4   2018-07-28 13:26:44.396463684 +0000
142 +++ libvirt-4.6.0/m4/virt-nss.m4        2018-08-20 18:00:20.572398013 +0000
143 @@ -27,9 +27,9 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[
144    bsd_nss=no
145    fail=0
146    if test "x$with_nss_plugin" != "xno" ; then
147 -    if test "x$with_jansson" != "xyes" ; then
148 +    if test "x$with_yajl" != "xyes" ; then
149        if test "x$with_nss_plugin" = "xyes" ; then
150 -        AC_MSG_ERROR([Can't build nss plugin without JSON support])
151 +        AC_MSG_ERROR([Can't build nss plugin without yajl])
152        else
153          with_nss_plugin=no
154        fi
155 diff -urNpa libvirt-4.6.0.orig/m4/virt-yajl.m4 libvirt-4.6.0/m4/virt-yajl.m4
156 --- libvirt-4.6.0.orig/m4/virt-yajl.m4  2018-07-28 13:26:44.396463684 +0000
157 +++ libvirt-4.6.0/m4/virt-yajl.m4       2018-08-20 18:00:20.572398013 +0000
158 @@ -23,10 +23,31 @@ AC_DEFUN([LIBVIRT_ARG_YAJL],[
159  
160  AC_DEFUN([LIBVIRT_CHECK_YAJL],[
161    dnl YAJL JSON library http://lloyd.github.com/yajl/
162 -  if test "$with_yajl" = yes; then
163 -    AC_MSG_ERROR([Compilation with YAJL is no longer supported])
164 +  if test "$with_qemu:$with_yajl" = yes:check; then
165 +    dnl Some versions of qemu require the use of yajl; try to detect them
166 +    dnl here, although we do not require qemu to exist in order to compile.
167 +    dnl This check mirrors src/qemu/qemu_capabilities.c
168 +    AC_PATH_PROGS([QEMU], [qemu-kvm qemu kvm qemu-system-x86_64],
169 +                  [], [$PATH:/usr/bin:/usr/libexec])
170 +    if test -x "$QEMU"; then
171 +      if $QEMU -help 2>/dev/null | grep -q libvirt; then
172 +        with_yajl=yes
173 +      else
174 +        [qemu_version_sed='s/.*ersion \([0-9.,]*\).*/\1/']
175 +        qemu_version=`$QEMU -version | sed "$qemu_version_sed"`
176 +        case $qemu_version in
177 +          [[1-9]].* | 0.15.* ) with_yajl=yes ;;
178 +          0.* | '' ) ;;
179 +          *) AC_MSG_ERROR([Unexpected qemu version string]) ;;
180 +        esac
181 +      fi
182 +    fi
183    fi
184 -  with_yajl=no
185 +
186 +  LIBVIRT_CHECK_LIB_ALT([YAJL], [yajl],
187 +                        [yajl_parse_complete], [yajl/yajl_common.h],
188 +                        [YAJL2], [yajl],
189 +                        [yajl_tree_parse], [yajl/yajl_common.h])
190  ])
191  
192  AC_DEFUN([LIBVIRT_RESULT_YAJL],[
193 diff -urNpa libvirt-4.6.0.orig/src/libvirt_private.syms libvirt-4.6.0/src/libvirt_private.syms
194 --- libvirt-4.6.0.orig/src/libvirt_private.syms 2018-08-02 03:58:35.114820107 +0000
195 +++ libvirt-4.6.0/src/libvirt_private.syms      2018-08-20 18:00:20.572398013 +0000
196 @@ -2098,6 +2098,7 @@ virJSONValueNewNumberUint;
197  virJSONValueNewNumberUlong;
198  virJSONValueNewObject;
199  virJSONValueNewString;
200 +virJSONValueNewStringLen;
201  virJSONValueObjectAdd;
202  virJSONValueObjectAddVArgs;
203  virJSONValueObjectAppend;
204 @@ -2135,10 +2136,6 @@ virJSONValueObjectStealObject;
205  virJSONValueToString;
206  
207  
208 -# util/virjsoncompat.h
209 -virJSONInitialize;
210 -
211 -
212  # util/virkeycode.h
213  virKeycodeSetTypeFromString;
214  virKeycodeSetTypeToString;
215 diff -urNpa libvirt-4.6.0.orig/src/Makefile.am libvirt-4.6.0/src/Makefile.am
216 --- libvirt-4.6.0.orig/src/Makefile.am  2018-08-02 03:58:35.114820107 +0000
217 +++ libvirt-4.6.0/src/Makefile.am       2018-08-20 18:04:33.691395163 +0000
218 @@ -544,7 +544,7 @@ libvirt_admin_la_CFLAGS = \
219  libvirt_admin_la_CFLAGS += \
220                 $(XDR_CFLAGS) \
221                 $(CAPNG_CFLAGS) \
222 -               $(JANSSON_CFLAGS) \
223 +               $(YAJL_CFLAGS) \
224                 $(SSH2_CFLAGS) \
225                 $(SASL_CFLAGS) \
226                 $(GNUTLS_CFLAGS) \
227 @@ -552,6 +552,7 @@ libvirt_admin_la_CFLAGS += \
228  
229  libvirt_admin_la_LIBADD += \
230                 $(CAPNG_LIBS) \
231 +               $(YAJL_LIBS) \
232                 $(DEVMAPPER_LIBS) \
233                 $(LIBXML_LIBS) \
234                 $(SSH2_LIBS) \
235 @@ -689,7 +690,6 @@ libvirt_setuid_rpc_client_la_SOURCES = \
236                 util/virhashcode.c \
237                 util/virhostcpu.c \
238                 util/virjson.c \
239 -               util/virjsoncompat.c \
240                 util/virlog.c \
241                 util/virobject.c \
242                 util/virpidfile.c \
243 @@ -961,8 +961,6 @@ libvirt_nss_la_SOURCES = \
244                 util/virhashcode.h \
245                 util/virjson.c \
246                 util/virjson.h \
247 -               util/virjsoncompat.c \
248 -               util/virjsoncompat.h \
249                 util/virkmod.c \
250                 util/virkmod.h \
251                 util/virlease.c \
252 @@ -996,11 +994,15 @@ libvirt_nss_la_SOURCES = \
253  libvirt_nss_la_CFLAGS = \
254                 -DLIBVIRT_NSS \
255                 $(AM_CFLAGS) \
256 -               $(JANSSON_CFLAGS) \
257 +               $(YAJL_CFLAGS) \
258                 $(NULL)
259  libvirt_nss_la_LDFLAGS = \
260                 $(AM_LDFLAGS) \
261                 $(NULL)
262 +
263 +libvirt_nss_la_LIBADD = \
264 +               $(YAJL_LIBS) \
265 +               $(NULL)
266  endif WITH_NSS
267  
268  
269 diff -urNpa libvirt-4.6.0.orig/src/qemu/qemu_driver.c libvirt-4.6.0/src/qemu/qemu_driver.c
270 --- libvirt-4.6.0.orig/src/qemu/qemu_driver.c   2018-07-31 03:31:26.316391201 +0000
271 +++ libvirt-4.6.0/src/qemu/qemu_driver.c        2018-08-20 18:00:20.575398013 +0000
272 @@ -2092,7 +2092,7 @@ qemuDomainReboot(virDomainPtr dom, unsig
273       */
274      if ((!useAgent) ||
275          (ret < 0 && (acpiRequested || !flags))) {
276 -#if !WITH_JANSSON
277 +#if !WITH_YAJL
278          virReportError(VIR_ERR_OPERATION_INVALID, "%s",
279                         _("ACPI reboot is not supported without the JSON monitor"));
280          goto endjob;
281 diff -urNpa libvirt-4.6.0.orig/src/remote/remote_daemon.c libvirt-4.6.0/src/remote/remote_daemon.c
282 --- libvirt-4.6.0.orig/src/remote/remote_daemon.c       2018-08-02 03:58:35.116820088 +0000
283 +++ libvirt-4.6.0/src/remote/remote_daemon.c    2018-08-20 18:00:20.575398013 +0000
284 @@ -59,7 +59,6 @@
285  #include "virutil.h"
286  #include "virgettext.h"
287  #include "util/virnetdevopenvswitch.h"
288 -#include "virjsoncompat.h"
289  
290  #include "driver.h"
291  
292 @@ -1184,9 +1183,6 @@ int main(int argc, char **argv) {
293          exit(EXIT_FAILURE);
294      }
295  
296 -    if (virJSONInitialize() < 0)
297 -        exit(EXIT_FAILURE);
298 -
299      daemonSetupNetDevOpenvswitch(config);
300  
301      if (daemonSetupAccessManager(config) < 0) {
302 diff -urNpa libvirt-4.6.0.orig/src/util/Makefile.inc.am libvirt-4.6.0/src/util/Makefile.inc.am
303 --- libvirt-4.6.0.orig/src/util/Makefile.inc.am 2018-08-02 03:58:35.116820088 +0000
304 +++ libvirt-4.6.0/src/util/Makefile.inc.am      2018-08-20 18:00:20.575398013 +0000
305 @@ -86,8 +86,6 @@ UTIL_SOURCES = \
306         util/viriscsi.h \
307         util/virjson.c \
308         util/virjson.h \
309 -       util/virjsoncompat.c \
310 -       util/virjsoncompat.h \
311         util/virkeycode.c \
312         util/virkeycode.h \
313         util/virkeyfile.c \
314 @@ -253,7 +251,7 @@ libvirt_util_la_SOURCES = \
315         $(NULL)
316  libvirt_util_la_CFLAGS = \
317         $(CAPNG_CFLAGS) \
318 -       $(JANSSON_CFLAGS) \
319 +       $(YAJL_CFLAGS) \
320         $(LIBNL_CFLAGS) \
321         $(AM_CFLAGS) \
322         $(AUDIT_CFLAGS) \
323 @@ -266,6 +264,7 @@ libvirt_util_la_CFLAGS = \
324         $(NULL)
325  libvirt_util_la_LIBADD = \
326         $(CAPNG_LIBS) \
327 +       $(YAJL_LIBS) \
328         $(LIBNL_LIBS) \
329         $(THREAD_LIBS) \
330         $(AUDIT_LIBS) \
331 diff -urNpa libvirt-4.6.0.orig/src/util/virjson.c libvirt-4.6.0/src/util/virjson.c
332 --- libvirt-4.6.0.orig/src/util/virjson.c       2018-08-02 03:58:35.117820079 +0000
333 +++ libvirt-4.6.0/src/util/virjson.c    2018-08-20 18:00:20.576398013 +0000
334 @@ -29,6 +29,22 @@
335  #include "virstring.h"
336  #include "virutil.h"
337  
338 +#if WITH_YAJL
339 +# include <yajl/yajl_gen.h>
340 +# include <yajl/yajl_parse.h>
341 +
342 +# ifdef WITH_YAJL2
343 +#  define yajl_size_t size_t
344 +#  define VIR_YAJL_STATUS_OK(status) ((status) == yajl_status_ok)
345 +# else
346 +#  define yajl_size_t unsigned int
347 +#  define yajl_complete_parse yajl_parse_complete
348 +#  define VIR_YAJL_STATUS_OK(status) \
349 +    ((status) == yajl_status_ok || (status) == yajl_status_insufficient_data)
350 +# endif
351 +
352 +#endif
353 +
354  /* XXX fixme */
355  #define VIR_FROM_THIS VIR_FROM_NONE
356  
357 @@ -72,6 +88,23 @@ struct _virJSONValue {
358  };
359  
360  
361 +typedef struct _virJSONParserState virJSONParserState;
362 +typedef virJSONParserState *virJSONParserStatePtr;
363 +struct _virJSONParserState {
364 +    virJSONValuePtr value;
365 +    char *key;
366 +};
367 +
368 +typedef struct _virJSONParser virJSONParser;
369 +typedef virJSONParser *virJSONParserPtr;
370 +struct _virJSONParser {
371 +    virJSONValuePtr head;
372 +    virJSONParserStatePtr state;
373 +    size_t nstate;
374 +    int wrap;
375 +};
376 +
377 +
378  virJSONType
379  virJSONValueGetType(const virJSONValue *value)
380  {
381 @@ -420,6 +453,28 @@ virJSONValueNewString(const char *data)
382  }
383  
384  
385 +virJSONValuePtr
386 +virJSONValueNewStringLen(const char *data,
387 +                         size_t length)
388 +{
389 +    virJSONValuePtr val;
390 +
391 +    if (!data)
392 +        return virJSONValueNewNull();
393 +
394 +    if (VIR_ALLOC(val) < 0)
395 +        return NULL;
396 +
397 +    val->type = VIR_JSON_TYPE_STRING;
398 +    if (VIR_STRNDUP(val->data.string, data, length) < 0) {
399 +        VIR_FREE(val);
400 +        return NULL;
401 +    }
402 +
403 +    return val;
404 +}
405 +
406 +
407  static virJSONValuePtr
408  virJSONValueNewNumber(const char *data)
409  {
410 @@ -1436,193 +1491,446 @@ virJSONValueCopy(const virJSONValue *in)
411  }
412  
413  
414 -#if WITH_JANSSON
415 +#if WITH_YAJL
416 +static int
417 +virJSONParserInsertValue(virJSONParserPtr parser,
418 +                         virJSONValuePtr value)
419 +{
420 +    if (!parser->head) {
421 +        parser->head = value;
422 +    } else {
423 +        virJSONParserStatePtr state;
424 +        if (!parser->nstate) {
425 +            VIR_DEBUG("got a value to insert without a container");
426 +            return -1;
427 +        }
428  
429 -# include "virjsoncompat.h"
430 +        state = &parser->state[parser->nstate-1];
431  
432 -static virJSONValuePtr
433 -virJSONValueFromJansson(json_t *json)
434 -{
435 -    virJSONValuePtr ret = NULL;
436 -    const char *key;
437 -    json_t *cur;
438 -    size_t i;
439 +        switch (state->value->type) {
440 +        case VIR_JSON_TYPE_OBJECT: {
441 +            if (!state->key) {
442 +                VIR_DEBUG("missing key when inserting object value");
443 +                return -1;
444 +            }
445  
446 -    switch (json_typeof(json)) {
447 -    case JSON_OBJECT:
448 -        ret = virJSONValueNewObject();
449 -        if (!ret)
450 -            goto error;
451 +            if (virJSONValueObjectAppend(state->value,
452 +                                         state->key,
453 +                                         value) < 0)
454 +                return -1;
455  
456 -        json_object_foreach(json, key, cur) {
457 -            virJSONValuePtr val = virJSONValueFromJansson(cur);
458 -            if (!val)
459 -                goto error;
460 +            VIR_FREE(state->key);
461 +        }   break;
462  
463 -            if (virJSONValueObjectAppend(ret, key, val) < 0) {
464 -                virJSONValueFree(val);
465 -                goto error;
466 +        case VIR_JSON_TYPE_ARRAY: {
467 +            if (state->key) {
468 +                VIR_DEBUG("unexpected key when inserting array value");
469 +                return -1;
470              }
471 +
472 +            if (virJSONValueArrayAppend(state->value,
473 +                                        value) < 0)
474 +                return -1;
475 +        }   break;
476 +
477 +        default:
478 +            VIR_DEBUG("unexpected value type, not a container");
479 +            return -1;
480          }
481 +    }
482  
483 -        break;
484 +    return 0;
485 +}
486  
487 -    case JSON_ARRAY:
488 -        ret = virJSONValueNewArray();
489 -        if (!ret)
490 -            goto error;
491  
492 -        json_array_foreach(json, i, cur) {
493 -            virJSONValuePtr val = virJSONValueFromJansson(cur);
494 -            if (!val)
495 -                goto error;
496 +static int
497 +virJSONParserHandleNull(void *ctx)
498 +{
499 +    virJSONParserPtr parser = ctx;
500 +    virJSONValuePtr value = virJSONValueNewNull();
501  
502 -            if (virJSONValueArrayAppend(ret, val) < 0) {
503 -                virJSONValueFree(val);
504 -                goto error;
505 -            }
506 -        }
507 -        break;
508 +    VIR_DEBUG("parser=%p", parser);
509  
510 -    case JSON_STRING:
511 -        ret = virJSONValueNewString(json_string_value(json));
512 -        break;
513 +    if (!value)
514 +        return 0;
515  
516 -    case JSON_INTEGER:
517 -        ret = virJSONValueNewNumberLong(json_integer_value(json));
518 -        break;
519 +    if (virJSONParserInsertValue(parser, value) < 0) {
520 +        virJSONValueFree(value);
521 +        return 0;
522 +    }
523  
524 -    case JSON_REAL:
525 -        ret = virJSONValueNewNumberDouble(json_real_value(json));
526 -        break;
527 +    return 1;
528 +}
529  
530 -    case JSON_TRUE:
531 -        ret = virJSONValueNewBoolean(true);
532 -        break;
533  
534 -    case JSON_FALSE:
535 -        ret = virJSONValueNewBoolean(false);
536 -        break;
537 +static int
538 +virJSONParserHandleBoolean(void *ctx,
539 +                           int boolean_)
540 +{
541 +    virJSONParserPtr parser = ctx;
542 +    virJSONValuePtr value = virJSONValueNewBoolean(boolean_);
543  
544 -    case JSON_NULL:
545 -        ret = virJSONValueNewNull();
546 -        break;
547 +    VIR_DEBUG("parser=%p boolean=%d", parser, boolean_);
548 +
549 +    if (!value)
550 +        return 0;
551 +
552 +    if (virJSONParserInsertValue(parser, value) < 0) {
553 +        virJSONValueFree(value);
554 +        return 0;
555      }
556  
557 -    return ret;
558 +    return 1;
559 +}
560  
561 - error:
562 -    virJSONValueFree(ret);
563 -    return NULL;
564 +
565 +static int
566 +virJSONParserHandleNumber(void *ctx,
567 +                          const char *s,
568 +                          yajl_size_t l)
569 +{
570 +    virJSONParserPtr parser = ctx;
571 +    char *str;
572 +    virJSONValuePtr value;
573 +
574 +    if (VIR_STRNDUP(str, s, l) < 0)
575 +        return -1;
576 +    value = virJSONValueNewNumber(str);
577 +    VIR_FREE(str);
578 +
579 +    VIR_DEBUG("parser=%p str=%s", parser, str);
580 +
581 +    if (!value)
582 +        return 0;
583 +
584 +    if (virJSONParserInsertValue(parser, value) < 0) {
585 +        virJSONValueFree(value);
586 +        return 0;
587 +    }
588 +
589 +    return 1;
590 +}
591 +
592 +
593 +static int
594 +virJSONParserHandleString(void *ctx,
595 +                          const unsigned char *stringVal,
596 +                          yajl_size_t stringLen)
597 +{
598 +    virJSONParserPtr parser = ctx;
599 +    virJSONValuePtr value = virJSONValueNewStringLen((const char *)stringVal,
600 +                                                     stringLen);
601 +
602 +    VIR_DEBUG("parser=%p str=%p", parser, (const char *)stringVal);
603 +
604 +    if (!value)
605 +        return 0;
606 +
607 +    if (virJSONParserInsertValue(parser, value) < 0) {
608 +        virJSONValueFree(value);
609 +        return 0;
610 +    }
611 +
612 +    return 1;
613 +}
614 +
615 +
616 +static int
617 +virJSONParserHandleMapKey(void *ctx,
618 +                          const unsigned char *stringVal,
619 +                          yajl_size_t stringLen)
620 +{
621 +    virJSONParserPtr parser = ctx;
622 +    virJSONParserStatePtr state;
623 +
624 +    VIR_DEBUG("parser=%p key=%p", parser, (const char *)stringVal);
625 +
626 +    if (!parser->nstate)
627 +        return 0;
628 +
629 +    state = &parser->state[parser->nstate-1];
630 +    if (state->key)
631 +        return 0;
632 +    if (VIR_STRNDUP(state->key, (const char *)stringVal, stringLen) < 0)
633 +        return 0;
634 +    return 1;
635  }
636  
637 +
638 +static int
639 +virJSONParserHandleStartMap(void *ctx)
640 +{
641 +    virJSONParserPtr parser = ctx;
642 +    virJSONValuePtr value = virJSONValueNewObject();
643 +
644 +    VIR_DEBUG("parser=%p", parser);
645 +
646 +    if (!value)
647 +        return 0;
648 +
649 +    if (virJSONParserInsertValue(parser, value) < 0) {
650 +        virJSONValueFree(value);
651 +        return 0;
652 +    }
653 +
654 +    if (VIR_REALLOC_N(parser->state,
655 +                      parser->nstate + 1) < 0) {
656 +        return 0;
657 +    }
658 +
659 +    parser->state[parser->nstate].value = value;
660 +    parser->state[parser->nstate].key = NULL;
661 +    parser->nstate++;
662 +
663 +    return 1;
664 +}
665 +
666 +
667 +static int
668 +virJSONParserHandleEndMap(void *ctx)
669 +{
670 +    virJSONParserPtr parser = ctx;
671 +    virJSONParserStatePtr state;
672 +
673 +    VIR_DEBUG("parser=%p", parser);
674 +
675 +    if (!parser->nstate)
676 +        return 0;
677 +
678 +    state = &(parser->state[parser->nstate-1]);
679 +    if (state->key) {
680 +        VIR_FREE(state->key);
681 +        return 0;
682 +    }
683 +
684 +    VIR_DELETE_ELEMENT(parser->state, parser->nstate - 1, parser->nstate);
685 +
686 +    return 1;
687 +}
688 +
689 +
690 +static int
691 +virJSONParserHandleStartArray(void *ctx)
692 +{
693 +    virJSONParserPtr parser = ctx;
694 +    virJSONValuePtr value = virJSONValueNewArray();
695 +
696 +    VIR_DEBUG("parser=%p", parser);
697 +
698 +    if (!value)
699 +        return 0;
700 +
701 +    if (virJSONParserInsertValue(parser, value) < 0) {
702 +        virJSONValueFree(value);
703 +        return 0;
704 +    }
705 +
706 +    if (VIR_REALLOC_N(parser->state,
707 +                      parser->nstate + 1) < 0)
708 +        return 0;
709 +
710 +    parser->state[parser->nstate].value = value;
711 +    parser->state[parser->nstate].key = NULL;
712 +    parser->nstate++;
713 +
714 +    return 1;
715 +}
716 +
717 +
718 +static int
719 +virJSONParserHandleEndArray(void *ctx)
720 +{
721 +    virJSONParserPtr parser = ctx;
722 +    virJSONParserStatePtr state;
723 +
724 +    VIR_DEBUG("parser=%p", parser);
725 +
726 +    if (!(parser->nstate - parser->wrap))
727 +        return 0;
728 +
729 +    state = &(parser->state[parser->nstate-1]);
730 +    if (state->key) {
731 +        VIR_FREE(state->key);
732 +        return 0;
733 +    }
734 +
735 +    VIR_DELETE_ELEMENT(parser->state, parser->nstate - 1, parser->nstate);
736 +
737 +    return 1;
738 +}
739 +
740 +
741 +static const yajl_callbacks parserCallbacks = {
742 +    virJSONParserHandleNull,
743 +    virJSONParserHandleBoolean,
744 +    NULL,
745 +    NULL,
746 +    virJSONParserHandleNumber,
747 +    virJSONParserHandleString,
748 +    virJSONParserHandleStartMap,
749 +    virJSONParserHandleMapKey,
750 +    virJSONParserHandleEndMap,
751 +    virJSONParserHandleStartArray,
752 +    virJSONParserHandleEndArray
753 +};
754 +
755 +
756 +/* XXX add an incremental streaming parser - yajl trivially supports it */
757  virJSONValuePtr
758  virJSONValueFromString(const char *jsonstring)
759  {
760 +    yajl_handle hand;
761 +    virJSONParser parser = { NULL, NULL, 0, 0 };
762      virJSONValuePtr ret = NULL;
763 -    json_t *json;
764 -    json_error_t error;
765 -    size_t flags = JSON_REJECT_DUPLICATES |
766 -                   JSON_DECODE_ANY;
767 +    int rc;
768 +    size_t len = strlen(jsonstring);
769 +# ifndef WITH_YAJL2
770 +    yajl_parser_config cfg = { 0, 1 }; /* Match yajl 2 default behavior */
771 +    VIR_AUTOPTR(virJSONValue) tmp = NULL;
772 +# endif
773 +
774 +    VIR_DEBUG("string=%s", jsonstring);
775 +
776 +# ifdef WITH_YAJL2
777 +    hand = yajl_alloc(&parserCallbacks, NULL, &parser);
778 +# else
779 +    hand = yajl_alloc(&parserCallbacks, &cfg, NULL, &parser);
780 +# endif
781 +    if (!hand) {
782 +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
783 +                       _("Unable to create JSON parser"));
784 +        goto cleanup;
785 +    }
786  
787 -    if (virJSONInitialize() < 0)
788 -        return NULL;
789 +    /* Yajl 2 is nice enough to default to rejecting trailing garbage.
790 +     * Yajl 1.0.12 has yajl_get_bytes_consumed to make that detection
791 +     * simpler.  But we're stuck with yajl 1.0.7 on RHEL 6, which
792 +     * happily quits parsing at the end of a valid JSON construct,
793 +     * with no visibility into how much more input remains.  Wrapping
794 +     * things in an array forces yajl to confess the truth.  */
795 +# ifdef WITH_YAJL2
796 +    rc = yajl_parse(hand, (const unsigned char *)jsonstring, len);
797 +# else
798 +    rc = yajl_parse(hand, (const unsigned char *)"[", 1);
799 +    parser.wrap = 1;
800 +    if (VIR_YAJL_STATUS_OK(rc))
801 +        rc = yajl_parse(hand, (const unsigned char *)jsonstring, len);
802 +    parser.wrap = 0;
803 +    if (VIR_YAJL_STATUS_OK(rc))
804 +        rc = yajl_parse(hand, (const unsigned char *)"]", 1);
805 +# endif
806 +    if (!VIR_YAJL_STATUS_OK(rc) ||
807 +        yajl_complete_parse(hand) != yajl_status_ok) {
808 +        unsigned char *errstr = yajl_get_error(hand, 1,
809 +                                               (const unsigned char*)jsonstring,
810 +                                               strlen(jsonstring));
811  
812 -    if (!(json = json_loads(jsonstring, flags, &error))) {
813          virReportError(VIR_ERR_INTERNAL_ERROR,
814 -                       _("failed to parse JSON %d:%d: %s"),
815 -                       error.line, error.column, error.text);
816 -        return NULL;
817 +                       _("cannot parse json %s: %s"),
818 +                       jsonstring, (const char*) errstr);
819 +        yajl_free_error(hand, errstr);
820 +        virJSONValueFree(parser.head);
821 +        goto cleanup;
822      }
823  
824 -    ret = virJSONValueFromJansson(json);
825 -    json_decref(json);
826 +    if (parser.nstate != 0) {
827 +        virReportError(VIR_ERR_INTERNAL_ERROR,
828 +                       _("cannot parse json %s: unterminated string/map/array"),
829 +                       jsonstring);
830 +        virJSONValueFree(parser.head);
831 +    } else {
832 +        ret = parser.head;
833 +# ifndef WITH_YAJL2
834 +        /* Undo the array wrapping above */
835 +        tmp = ret;
836 +        ret = NULL;
837 +        if (virJSONValueArraySize(tmp) > 1)
838 +            virReportError(VIR_ERR_INTERNAL_ERROR,
839 +                           _("cannot parse json %s: too many items present"),
840 +                           jsonstring);
841 +        else
842 +            ret = virJSONValueArraySteal(tmp, 0);
843 +# endif
844 +    }
845 +
846 + cleanup:
847 +    yajl_free(hand);
848 +
849 +    if (parser.nstate) {
850 +        size_t i;
851 +        for (i = 0; i < parser.nstate; i++)
852 +            VIR_FREE(parser.state[i].key);
853 +        VIR_FREE(parser.state);
854 +    }
855 +
856 +    VIR_DEBUG("result=%p", ret);
857 +
858      return ret;
859  }
860  
861  
862 -static json_t *
863 -virJSONValueToJansson(virJSONValuePtr object)
864 +static int
865 +virJSONValueToStringOne(virJSONValuePtr object,
866 +                        yajl_gen g)
867  {
868 -    json_t *ret = NULL;
869      size_t i;
870  
871 -    switch ((virJSONType)object->type) {
872 +    VIR_DEBUG("object=%p type=%d gen=%p", object, object->type, g);
873 +
874 +    switch (object->type) {
875      case VIR_JSON_TYPE_OBJECT:
876 -        ret = json_object();
877 -        if (!ret)
878 -            goto no_memory;
879 +        if (yajl_gen_map_open(g) != yajl_gen_status_ok)
880 +            return -1;
881          for (i = 0; i < object->data.object.npairs; i++) {
882 -            virJSONObjectPairPtr cur = object->data.object.pairs + i;
883 -            json_t *val = virJSONValueToJansson(cur->value);
884 -
885 -            if (!val)
886 -                goto error;
887 -            if (json_object_set_new(ret, cur->key, val) < 0) {
888 -                json_decref(val);
889 -                goto no_memory;
890 -            }
891 +            if (yajl_gen_string(g,
892 +                                (unsigned char *)object->data.object.pairs[i].key,
893 +                                strlen(object->data.object.pairs[i].key))
894 +                                != yajl_gen_status_ok)
895 +                return -1;
896 +            if (virJSONValueToStringOne(object->data.object.pairs[i].value, g) < 0)
897 +                return -1;
898          }
899 +        if (yajl_gen_map_close(g) != yajl_gen_status_ok)
900 +            return -1;
901          break;
902 -
903      case VIR_JSON_TYPE_ARRAY:
904 -        ret = json_array();
905 -        if (!ret)
906 -            goto no_memory;
907 +        if (yajl_gen_array_open(g) != yajl_gen_status_ok)
908 +            return -1;
909          for (i = 0; i < object->data.array.nvalues; i++) {
910 -            virJSONValuePtr cur = object->data.array.values[i];
911 -            json_t *val = virJSONValueToJansson(cur);
912 -
913 -            if (!val)
914 -                goto error;
915 -            if (json_array_append_new(ret, val) < 0) {
916 -                json_decref(val);
917 -                goto no_memory;
918 -            }
919 +            if (virJSONValueToStringOne(object->data.array.values[i], g) < 0)
920 +                return -1;
921          }
922 +        if (yajl_gen_array_close(g) != yajl_gen_status_ok)
923 +            return -1;
924          break;
925  
926      case VIR_JSON_TYPE_STRING:
927 -        ret = json_string(object->data.string);
928 +        if (yajl_gen_string(g, (unsigned char *)object->data.string,
929 +                            strlen(object->data.string)) != yajl_gen_status_ok)
930 +            return -1;
931          break;
932  
933 -    case VIR_JSON_TYPE_NUMBER: {
934 -        long long ll_val;
935 -        double d_val;
936 -        if (virStrToLong_ll(object->data.number, NULL, 10, &ll_val) < 0) {
937 -            if (virStrToDouble(object->data.number, NULL, &d_val) < 0) {
938 -                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
939 -                               _("JSON value is not a number"));
940 -                return NULL;
941 -            }
942 -            ret = json_real(d_val);
943 -        } else {
944 -            ret = json_integer(ll_val);
945 -        }
946 -    }
947 +    case VIR_JSON_TYPE_NUMBER:
948 +        if (yajl_gen_number(g, object->data.number,
949 +                            strlen(object->data.number)) != yajl_gen_status_ok)
950 +            return -1;
951          break;
952  
953      case VIR_JSON_TYPE_BOOLEAN:
954 -        ret = json_boolean(object->data.boolean);
955 +        if (yajl_gen_bool(g, object->data.boolean) != yajl_gen_status_ok)
956 +            return -1;
957          break;
958  
959      case VIR_JSON_TYPE_NULL:
960 -        ret = json_null();
961 +        if (yajl_gen_null(g) != yajl_gen_status_ok)
962 +            return -1;
963          break;
964  
965      default:
966 -        virReportEnumRangeError(virJSONType, object->type);
967 -        goto error;
968 +        return -1;
969      }
970 -    if (!ret)
971 -        goto no_memory;
972 -    return ret;
973  
974 - no_memory:
975 -    virReportOOMError();
976 - error:
977 -    json_decref(ret);
978 -    return NULL;
979 +    return 0;
980  }
981  
982  
983 @@ -1630,27 +1938,50 @@ char *
984  virJSONValueToString(virJSONValuePtr object,
985                       bool pretty)
986  {
987 -    size_t flags = JSON_ENCODE_ANY;
988 -    json_t *json;
989 -    char *str = NULL;
990 +    yajl_gen g;
991 +    const unsigned char *str;
992 +    char *ret = NULL;
993 +    yajl_size_t len;
994 +# ifndef WITH_YAJL2
995 +    yajl_gen_config conf = { pretty ? 1 : 0, pretty ? "  " : " "};
996 +# endif
997 +
998 +    VIR_DEBUG("object=%p", object);
999 +
1000 +# ifdef WITH_YAJL2
1001 +    g = yajl_gen_alloc(NULL);
1002 +    if (g) {
1003 +        yajl_gen_config(g, yajl_gen_beautify, pretty ? 1 : 0);
1004 +        yajl_gen_config(g, yajl_gen_indent_string, pretty ? "  " : " ");
1005 +        yajl_gen_config(g, yajl_gen_validate_utf8, 1);
1006 +    }
1007 +# else
1008 +    g = yajl_gen_alloc(&conf, NULL);
1009 +# endif
1010 +    if (!g) {
1011 +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
1012 +                       _("Unable to create JSON formatter"));
1013 +        goto cleanup;
1014 +    }
1015  
1016 -    if (virJSONInitialize() < 0)
1017 -        return NULL;
1018 +    if (virJSONValueToStringOne(object, g) < 0) {
1019 +        virReportOOMError();
1020 +        goto cleanup;
1021 +    }
1022  
1023 -    if (pretty)
1024 -        flags |= JSON_INDENT(2);
1025 -    else
1026 -        flags |= JSON_COMPACT;
1027 +    if (yajl_gen_get_buf(g, &str, &len) != yajl_gen_status_ok) {
1028 +        virReportOOMError();
1029 +        goto cleanup;
1030 +    }
1031  
1032 -    json = virJSONValueToJansson(object);
1033 -    if (!json)
1034 -        return NULL;
1035 +    ignore_value(VIR_STRDUP(ret, (const char *)str));
1036  
1037 -    str = json_dumps(json, flags);
1038 -    if (!str)
1039 -        virReportOOMError();
1040 -    json_decref(json);
1041 -    return str;
1042 + cleanup:
1043 +    yajl_gen_free(g);
1044 +
1045 +    VIR_DEBUG("result=%s", NULLSTR(ret));
1046 +
1047 +    return ret;
1048  }
1049  
1050  
1051 diff -urNpa libvirt-4.6.0.orig/src/util/virjsoncompat.c libvirt-4.6.0/src/util/virjsoncompat.c
1052 --- libvirt-4.6.0.orig/src/util/virjsoncompat.c 2018-08-02 03:58:35.117820079 +0000
1053 +++ libvirt-4.6.0/src/util/virjsoncompat.c      1970-01-01 00:00:00.000000000 +0000
1054 @@ -1,285 +0,0 @@
1055 -/*
1056 - * virjsoncompat.c: JSON object parsing/formatting
1057 - *
1058 - * Copyright (C) 2018 Red Hat, Inc.
1059 - *
1060 - * This library is free software; you can redistribute it and/or
1061 - * modify it under the terms of the GNU Lesser General Public
1062 - * License as published by the Free Software Foundation; either
1063 - * version 2.1 of the License, or (at your option) any later version.
1064 - *
1065 - * This library is distributed in the hope that it will be useful,
1066 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1067 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1068 - * Lesser General Public License for more details.
1069 - *
1070 - * You should have received a copy of the GNU Lesser General Public
1071 - * License along with this library.  If not, see
1072 - * <http://www.gnu.org/licenses/>.
1073 - *
1074 - */
1075 -
1076 -#include <config.h>
1077 -
1078 -#include "virthread.h"
1079 -#include "virerror.h"
1080 -#define VIR_JSON_COMPAT_IMPL
1081 -#include "virjsoncompat.h"
1082 -
1083 -#define VIR_FROM_THIS VIR_FROM_NONE
1084 -
1085 -#if WITH_JANSSON
1086 -
1087 -# include <dlfcn.h>
1088 -
1089 -json_t *(*json_array_ptr)(void);
1090 -int (*json_array_append_new_ptr)(json_t *array, json_t *value);
1091 -json_t *(*json_array_get_ptr)(const json_t *array, size_t index);
1092 -size_t (*json_array_size_ptr)(const json_t *array);
1093 -void (*json_delete_ptr)(json_t *json);
1094 -char *(*json_dumps_ptr)(const json_t *json, size_t flags);
1095 -json_t *(*json_false_ptr)(void);
1096 -json_t *(*json_integer_ptr)(json_int_t value);
1097 -json_int_t (*json_integer_value_ptr)(const json_t *integer);
1098 -json_t *(*json_loads_ptr)(const char *input, size_t flags, json_error_t *error);
1099 -json_t *(*json_null_ptr)(void);
1100 -json_t *(*json_object_ptr)(void);
1101 -void *(*json_object_iter_ptr)(json_t *object);
1102 -const char *(*json_object_iter_key_ptr)(void *iter);
1103 -void *(*json_object_iter_next_ptr)(json_t *object, void *iter);
1104 -json_t *(*json_object_iter_value_ptr)(void *iter);
1105 -void *(*json_object_key_to_iter_ptr)(const char *key);
1106 -int (*json_object_set_new_ptr)(json_t *object, const char *key, json_t *value);
1107 -json_t *(*json_real_ptr)(double value);
1108 -double (*json_real_value_ptr)(const json_t *real);
1109 -json_t *(*json_string_ptr)(const char *value);
1110 -const char *(*json_string_value_ptr)(const json_t *string);
1111 -json_t *(*json_true_ptr)(void);
1112 -
1113 -
1114 -static int
1115 -virJSONJanssonOnceInit(void)
1116 -{
1117 -    void *handle = dlopen("libjansson.so.4", RTLD_LAZY|RTLD_LOCAL|RTLD_NODELETE);
1118 -    if (!handle) {
1119 -        virReportError(VIR_ERR_NO_SUPPORT,
1120 -                       _("libjansson.so.4 JSON library not available: %s"), dlerror());
1121 -        return -1;
1122 -    }
1123 -
1124 -# define LOAD(name) \
1125 -    do { \
1126 -        if (!(name ## _ptr = dlsym(handle, #name))) { \
1127 -            virReportError(VIR_ERR_NO_SUPPORT, \
1128 -                           _("missing symbol '%s' in libjansson.so.4: %s"), #name, dlerror()); \
1129 -            return -1; \
1130 -        } \
1131 -    } while (0)
1132 -
1133 -    LOAD(json_array);
1134 -    LOAD(json_array_append_new);
1135 -    LOAD(json_array_get);
1136 -    LOAD(json_array_size);
1137 -    LOAD(json_delete);
1138 -    LOAD(json_dumps);
1139 -    LOAD(json_false);
1140 -    LOAD(json_integer);
1141 -    LOAD(json_integer_value);
1142 -    LOAD(json_loads);
1143 -    LOAD(json_null);
1144 -    LOAD(json_object);
1145 -    LOAD(json_object_iter);
1146 -    LOAD(json_object_iter_key);
1147 -    LOAD(json_object_iter_next);
1148 -    LOAD(json_object_iter_value);
1149 -    LOAD(json_object_key_to_iter);
1150 -    LOAD(json_object_set_new);
1151 -    LOAD(json_real);
1152 -    LOAD(json_real_value);
1153 -    LOAD(json_string);
1154 -    LOAD(json_string_value);
1155 -    LOAD(json_true);
1156 -
1157 -    return 0;
1158 -}
1159 -
1160 -VIR_ONCE_GLOBAL_INIT(virJSONJansson);
1161 -
1162 -int
1163 -virJSONInitialize(void)
1164 -{
1165 -    return virJSONJanssonInitialize();
1166 -}
1167 -
1168 -json_t *
1169 -json_array_impl(void)
1170 -{
1171 -    return json_array_ptr();
1172 -}
1173 -
1174 -
1175 -int
1176 -json_array_append_new_impl(json_t *array, json_t *value)
1177 -{
1178 -    return json_array_append_new_ptr(array, value);
1179 -}
1180 -
1181 -
1182 -json_t *
1183 -json_array_get_impl(const json_t *array, size_t index)
1184 -{
1185 -    return json_array_get_ptr(array, index);
1186 -}
1187 -
1188 -
1189 -size_t
1190 -json_array_size_impl(const json_t *array)
1191 -{
1192 -    return json_array_size_ptr(array);
1193 -}
1194 -
1195 -
1196 -void
1197 -json_delete_impl(json_t *json)
1198 -{
1199 -    return json_delete_ptr(json);
1200 -}
1201 -
1202 -
1203 -char *
1204 -json_dumps_impl(const json_t *json, size_t flags)
1205 -{
1206 -    return json_dumps_ptr(json, flags);
1207 -}
1208 -
1209 -
1210 -json_t *
1211 -json_false_impl(void)
1212 -{
1213 -    return json_false_ptr();
1214 -}
1215 -
1216 -
1217 -json_t *
1218 -json_integer_impl(json_int_t value)
1219 -{
1220 -    return json_integer_ptr(value);
1221 -}
1222 -
1223 -
1224 -json_int_t
1225 -json_integer_value_impl(const json_t *integer)
1226 -{
1227 -    return json_integer_value_ptr(integer);
1228 -}
1229 -
1230 -
1231 -json_t *
1232 -json_loads_impl(const char *input, size_t flags, json_error_t *error)
1233 -{
1234 -    return json_loads_ptr(input, flags, error);
1235 -}
1236 -
1237 -
1238 -json_t *
1239 -json_null_impl(void)
1240 -{
1241 -    return json_null_ptr();
1242 -}
1243 -
1244 -
1245 -json_t *
1246 -json_object_impl(void)
1247 -{
1248 -    return json_object_ptr();
1249 -}
1250 -
1251 -
1252 -void *
1253 -json_object_iter_impl(json_t *object)
1254 -{
1255 -    return json_object_iter_ptr(object);
1256 -}
1257 -
1258 -
1259 -const char *
1260 -json_object_iter_key_impl(void *iter)
1261 -{
1262 -    return json_object_iter_key_ptr(iter);
1263 -}
1264 -
1265 -
1266 -void *
1267 -json_object_iter_next_impl(json_t *object, void *iter)
1268 -{
1269 -    return json_object_iter_next_ptr(object, iter);
1270 -}
1271 -
1272 -
1273 -json_t *
1274 -json_object_iter_value_impl(void *iter)
1275 -{
1276 -    return json_object_iter_value_ptr(iter);
1277 -}
1278 -
1279 -
1280 -void *
1281 -json_object_key_to_iter_impl(const char *key)
1282 -{
1283 -    return json_object_key_to_iter_ptr(key);
1284 -}
1285 -
1286 -
1287 -int
1288 -json_object_set_new_impl(json_t *object, const char *key, json_t *value)
1289 -{
1290 -    return json_object_set_new_ptr(object, key, value);
1291 -}
1292 -
1293 -
1294 -json_t *
1295 -json_real_impl(double value)
1296 -{
1297 -    return json_real_ptr(value);
1298 -}
1299 -
1300 -
1301 -double
1302 -json_real_value_impl(const json_t *real)
1303 -{
1304 -    return json_real_value_ptr(real);
1305 -}
1306 -
1307 -
1308 -json_t *
1309 -json_string_impl(const char *value)
1310 -{
1311 -    return json_string_ptr(value);
1312 -}
1313 -
1314 -
1315 -const char *
1316 -json_string_value_impl(const json_t *string)
1317 -{
1318 -    return json_string_value_ptr(string);
1319 -}
1320 -
1321 -
1322 -json_t *
1323 -json_true_impl(void)
1324 -{
1325 -    return json_true_ptr();
1326 -}
1327 -
1328 -
1329 -#else /* !WITH_JANSSON */
1330 -
1331 -
1332 -int
1333 -virJSONInitialize(void)
1334 -{
1335 -    return 0;
1336 -}
1337 -
1338 -
1339 -#endif /* !WITH_JANSSON */
1340 diff -urNpa libvirt-4.6.0.orig/src/util/virjsoncompat.h libvirt-4.6.0/src/util/virjsoncompat.h
1341 --- libvirt-4.6.0.orig/src/util/virjsoncompat.h 2018-08-02 03:58:35.117820079 +0000
1342 +++ libvirt-4.6.0/src/util/virjsoncompat.h      1970-01-01 00:00:00.000000000 +0000
1343 @@ -1,88 +0,0 @@
1344 -/*
1345 - * virjsoncompat.h: JSON object parsing/formatting
1346 - *
1347 - * Copyright (C) 2018 Red Hat, Inc.
1348 - *
1349 - * This library is free software; you can redistribute it and/or
1350 - * modify it under the terms of the GNU Lesser General Public
1351 - * License as published by the Free Software Foundation; either
1352 - * version 2.1 of the License, or (at your option) any later version.
1353 - *
1354 - * This library is distributed in the hope that it will be useful,
1355 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1356 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1357 - * Lesser General Public License for more details.
1358 - *
1359 - * You should have received a copy of the GNU Lesser General Public
1360 - * License along with this library.  If not, see
1361 - * <http://www.gnu.org/licenses/>.
1362 - *
1363 - */
1364 -
1365 -
1366 -#ifndef __VIR_JSON_COMPAT_H_
1367 -# define __VIR_JSON_COMPAT_H_
1368 -
1369 -# if WITH_JANSSON
1370 -#  ifndef VIR_JSON_COMPAT_IMPL
1371 -
1372 -#   define json_array json_array_impl
1373 -#   define json_array_append_new json_array_append_new_impl
1374 -#   define json_array_get json_array_get_impl
1375 -#   define json_array_size json_array_size_impl
1376 -#   define json_delete json_delete_impl
1377 -#   define json_dumps json_dumps_impl
1378 -#   define json_false json_false_impl
1379 -#   define json_integer json_integer_impl
1380 -#   define json_integer_value json_integer_value_impl
1381 -#   define json_loads json_loads_impl
1382 -#   define json_null json_null_impl
1383 -#   define json_object json_object_impl
1384 -#   define json_object_iter json_object_iter_impl
1385 -#   define json_object_iter_key json_object_iter_key_impl
1386 -#   define json_object_iter_next json_object_iter_next_impl
1387 -#   define json_object_iter_value json_object_iter_value_impl
1388 -#   define json_object_key_to_iter json_object_key_to_iter_impl
1389 -#   define json_object_set_new json_object_set_new_impl
1390 -#   define json_real json_real_impl
1391 -#   define json_real_value json_real_value_impl
1392 -#   define json_string json_string_impl
1393 -#   define json_string_value json_string_value_impl
1394 -#   define json_true json_true_impl
1395 -
1396 -#  endif /* ! VIR_JSON_COMPAT_IMPL */
1397 -
1398 -#  include <jansson.h>
1399 -
1400 -#  ifdef VIR_JSON_COMPAT_IMPL
1401 -
1402 -json_t *json_array_impl(void);
1403 -int json_array_append_new_impl(json_t *array, json_t *value);
1404 -json_t *json_array_get_impl(const json_t *array, size_t index);
1405 -size_t json_array_size_impl(const json_t *array);
1406 -void json_delete_impl(json_t *json);
1407 -char *json_dumps_impl(const json_t *json, size_t flags);
1408 -json_t *json_false_impl(void);
1409 -json_t *json_integer_impl(json_int_t value);
1410 -json_int_t json_integer_value_impl(const json_t *integer);
1411 -json_t *json_loads_impl(const char *input, size_t flags, json_error_t *error);
1412 -json_t *json_null_impl(void);
1413 -json_t *json_object_impl(void);
1414 -void *json_object_iter_impl(json_t *object);
1415 -const char *json_object_iter_key_impl(void *iter);
1416 -void *json_object_iter_next_impl(json_t *object, void *iter);
1417 -json_t *json_object_iter_value_impl(void *iter);
1418 -void *json_object_key_to_iter_impl(const char *key);
1419 -int json_object_set_new_impl(json_t *object, const char *key, json_t *value);
1420 -json_t *json_real_impl(double value);
1421 -double json_real_value_impl(const json_t *real);
1422 -json_t *json_string_impl(const char *value);
1423 -const char *json_string_value_impl(const json_t *string);
1424 -json_t *json_true_impl(void);
1425 -
1426 -#  endif /* VIR_JSON_COMPAT_IMPL */
1427 -# endif /* WITH_JANSSON */
1428 -
1429 -int virJSONInitialize(void);
1430 -
1431 -#endif /* __VIR_JSON_COMPAT_H_ */
1432 diff -urNpa libvirt-4.6.0.orig/src/util/virjson.h libvirt-4.6.0/src/util/virjson.h
1433 --- libvirt-4.6.0.orig/src/util/virjson.h       2018-07-28 13:26:44.464463065 +0000
1434 +++ libvirt-4.6.0/src/util/virjson.h    2018-08-20 18:00:20.576398013 +0000
1435 @@ -59,6 +59,7 @@ int virJSONValueObjectAddVArgs(virJSONVa
1436  
1437  
1438  virJSONValuePtr virJSONValueNewString(const char *data);
1439 +virJSONValuePtr virJSONValueNewStringLen(const char *data, size_t length);
1440  virJSONValuePtr virJSONValueNewNumberInt(int data);
1441  virJSONValuePtr virJSONValueNewNumberUint(unsigned int data);
1442  virJSONValuePtr virJSONValueNewNumberLong(long long data);
1443 diff -urNpa libvirt-4.6.0.orig/tests/cputest.c libvirt-4.6.0/tests/cputest.c
1444 --- libvirt-4.6.0.orig/tests/cputest.c  2018-07-28 13:26:44.475462965 +0000
1445 +++ libvirt-4.6.0/tests/cputest.c       2018-08-20 18:00:20.576398013 +0000
1446 @@ -40,7 +40,7 @@
1447  #include "cpu/cpu_map.h"
1448  #include "virstring.h"
1449  
1450 -#if WITH_QEMU && WITH_JANSSON
1451 +#if WITH_QEMU && WITH_YAJL
1452  # include "testutilsqemu.h"
1453  # include "qemumonitortestutils.h"
1454  # define __QEMU_CAPSPRIV_H_ALLOW__
1455 @@ -67,7 +67,7 @@ struct data {
1456      int result;
1457  };
1458  
1459 -#if WITH_QEMU && WITH_JANSSON
1460 +#if WITH_QEMU && WITH_YAJL
1461  static virQEMUDriver driver;
1462  #endif
1463  
1464 @@ -479,7 +479,7 @@ typedef enum {
1465      JSON_MODELS_REQUIRED,
1466  } cpuTestCPUIDJson;
1467  
1468 -#if WITH_QEMU && WITH_JANSSON
1469 +#if WITH_QEMU && WITH_YAJL
1470  static virQEMUCapsPtr
1471  cpuTestMakeQEMUCaps(const struct data *data)
1472  {
1473 @@ -554,7 +554,7 @@ cpuTestGetCPUModels(const struct data *d
1474      return 0;
1475  }
1476  
1477 -#else /* if WITH_QEMU && WITH_JANSSON */
1478 +#else /* if WITH_QEMU && WITH_YAJL */
1479  
1480  static int
1481  cpuTestGetCPUModels(const struct data *data,
1482 @@ -834,7 +834,7 @@ cpuTestUpdateLive(const void *arg)
1483  }
1484  
1485  
1486 -#if WITH_QEMU && WITH_JANSSON
1487 +#if WITH_QEMU && WITH_YAJL
1488  static int
1489  cpuTestJSONCPUID(const void *arg)
1490  {
1491 @@ -911,7 +911,7 @@ mymain(void)
1492      virDomainCapsCPUModelsPtr ppc_models = NULL;
1493      int ret = 0;
1494  
1495 -#if WITH_QEMU && WITH_JANSSON
1496 +#if WITH_QEMU && WITH_YAJL
1497      if (qemuTestDriverInit(&driver) < 0)
1498          return EXIT_FAILURE;
1499  
1500 @@ -1004,7 +1004,7 @@ mymain(void)
1501              host "/" cpu " (" #models ")", \
1502              host, cpu, models, 0, result)
1503  
1504 -#if WITH_QEMU && WITH_JANSSON
1505 +#if WITH_QEMU && WITH_YAJL
1506  # define DO_TEST_JSON(arch, host, json) \
1507      do { \
1508          if (json == JSON_MODELS) { \
1509 @@ -1205,7 +1205,7 @@ mymain(void)
1510      DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-X5460", JSON_NONE);
1511  
1512   cleanup:
1513 -#if WITH_QEMU && WITH_JANSSON
1514 +#if WITH_QEMU && WITH_YAJL
1515      qemuTestDriverFree(&driver);
1516  #endif
1517  
1518 diff -urNpa libvirt-4.6.0.orig/tests/libxlxml2domconfigtest.c libvirt-4.6.0/tests/libxlxml2domconfigtest.c
1519 --- libvirt-4.6.0.orig/tests/libxlxml2domconfigtest.c   2018-08-06 09:22:16.558995687 +0000
1520 +++ libvirt-4.6.0/tests/libxlxml2domconfigtest.c        2018-08-20 18:00:20.576398013 +0000
1521 @@ -33,7 +33,7 @@
1522  
1523  #include "testutils.h"
1524  
1525 -#if defined(WITH_LIBXL) && defined(WITH_JANSSON) && defined(HAVE_LIBXL_DOMAIN_CONFIG_FROM_JSON)
1526 +#if defined(WITH_LIBXL) && defined(WITH_YAJL) && defined(HAVE_LIBXL_DOMAIN_CONFIG_FROM_JSON)
1527  
1528  # include "internal.h"
1529  # include "viralloc.h"
1530 @@ -228,4 +228,4 @@ int main(void)
1531      return EXIT_AM_SKIP;
1532  }
1533  
1534 -#endif /* WITH_LIBXL && WITH_JANSSON && HAVE_LIBXL_DOMAIN_CONFIG_FROM_JSON */
1535 +#endif /* WITH_LIBXL && WITH_YAJL && HAVE_LIBXL_DOMAIN_CONFIG_FROM_JSON */
1536 diff -urNpa libvirt-4.6.0.orig/tests/Makefile.am libvirt-4.6.0/tests/Makefile.am
1537 --- libvirt-4.6.0.orig/tests/Makefile.am        2018-07-28 13:26:44.475462965 +0000
1538 +++ libvirt-4.6.0/tests/Makefile.am     2018-08-20 18:00:20.576398013 +0000
1539 @@ -46,7 +46,7 @@ AM_CFLAGS = \
1540         $(SASL_CFLAGS) \
1541         $(SELINUX_CFLAGS) \
1542         $(APPARMOR_CFLAGS) \
1543 -       $(JANSSON_CFLAGS) \
1544 +       $(YAJL_CFLAGS) \
1545         $(COVERAGE_CFLAGS) \
1546         $(XDR_CFLAGS) \
1547         $(WARN_CFLAGS)
1548 @@ -331,9 +331,9 @@ if WITH_CIL
1549  test_programs += objectlocking
1550  endif WITH_CIL
1551  
1552 -if WITH_JANSSON
1553 +if WITH_YAJL
1554  test_programs += virjsontest
1555 -endif WITH_JANSSON
1556 +endif WITH_YAJL
1557  
1558  test_programs += \
1559                 networkxml2xmltest \
1560 @@ -1219,15 +1219,15 @@ virdeterministichashmock_la_LIBADD = $(M
1561  
1562  test_libraries += virdeterministichashmock.la
1563  
1564 -if WITH_JANSSON
1565 +if WITH_YAJL
1566  virmacmaptest_SOURCES = \
1567         virmacmaptest.c testutils.h testutils.c
1568  virmacmaptest_LDADD = $(LDADDS)
1569  
1570  test_programs += virmacmaptest
1571 -else ! WITH_JANSSON
1572 +else ! WITH_YAJL
1573  EXTRA_DIST +=  virmacmaptest.c
1574 -endif ! WITH_JANSSON
1575 +endif ! WITH_YAJL
1576  
1577  virnetdevtest_SOURCES = \
1578         virnetdevtest.c testutils.h testutils.c
1579 diff -urNpa libvirt-4.6.0.orig/tests/qemuagenttest.c libvirt-4.6.0/tests/qemuagenttest.c
1580 --- libvirt-4.6.0.orig/tests/qemuagenttest.c    2018-07-28 13:26:44.477462947 +0000
1581 +++ libvirt-4.6.0/tests/qemuagenttest.c 2018-08-20 18:00:20.576398013 +0000
1582 @@ -907,8 +907,8 @@ mymain(void)
1583  {
1584      int ret = 0;
1585  
1586 -#if !WITH_STABLE_ORDERING_JANSSON
1587 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1588 +#if !WITH_YAJL
1589 +    fputs("libvirt not compiled with JSON support, skipping this test\n", stderr);
1590      return EXIT_AM_SKIP;
1591  #endif
1592  
1593 diff -urNpa libvirt-4.6.0.orig/tests/qemublocktest.c libvirt-4.6.0/tests/qemublocktest.c
1594 --- libvirt-4.6.0.orig/tests/qemublocktest.c    2018-07-28 13:26:44.477462947 +0000
1595 +++ libvirt-4.6.0/tests/qemublocktest.c 2018-08-20 18:00:20.577398013 +0000
1596 @@ -309,7 +309,6 @@ testQemuDiskXMLToPropsValidateFile(const
1597              goto cleanup;
1598  
1599          virBufferAdd(&buf, jsonstr, -1);
1600 -        virBufferAddLit(&buf, "\n");
1601          VIR_FREE(jsonstr);
1602      }
1603  
1604 @@ -337,11 +336,6 @@ mymain(void)
1605      char *capslatest_x86_64 = NULL;
1606      virQEMUCapsPtr caps_x86_64 = NULL;
1607  
1608 -#if !WITH_STABLE_ORDERING_JANSSON
1609 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1610 -    return EXIT_AM_SKIP;
1611 -#endif
1612 -
1613      if (qemuTestDriverInit(&driver) < 0)
1614          return EXIT_FAILURE;
1615  
1616 diff -urNpa libvirt-4.6.0.orig/tests/qemucapabilitiestest.c libvirt-4.6.0/tests/qemucapabilitiestest.c
1617 --- libvirt-4.6.0.orig/tests/qemucapabilitiestest.c     2018-07-28 13:26:44.484462883 +0000
1618 +++ libvirt-4.6.0/tests/qemucapabilitiestest.c  2018-08-20 18:00:20.577398013 +0000
1619 @@ -141,12 +141,7 @@ mymain(void)
1620      int ret = 0;
1621      testQemuData data;
1622  
1623 -#if !WITH_STABLE_ORDERING_JANSSON
1624 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1625 -    return EXIT_AM_SKIP;
1626 -#endif
1627 -
1628 -#if !WITH_JANSSON
1629 +#if !WITH_YAJL
1630      fputs("libvirt not compiled with JSON support, skipping this test\n", stderr);
1631      return EXIT_AM_SKIP;
1632  #endif
1633 diff -urNpa libvirt-4.6.0.orig/tests/qemucaps2xmltest.c libvirt-4.6.0/tests/qemucaps2xmltest.c
1634 --- libvirt-4.6.0.orig/tests/qemucaps2xmltest.c 2018-07-28 13:26:44.484462883 +0000
1635 +++ libvirt-4.6.0/tests/qemucaps2xmltest.c      2018-08-20 18:00:20.577398013 +0000
1636 @@ -165,7 +165,7 @@ mymain(void)
1637  
1638      testQemuData data;
1639  
1640 -#if !WITH_JANSSON
1641 +#if !WITH_YAJL
1642      fputs("libvirt not compiled with JSON support, skipping this test\n", stderr);
1643      return EXIT_AM_SKIP;
1644  #endif
1645 diff -urNpa libvirt-4.6.0.orig/tests/qemucapsprobemock.c libvirt-4.6.0/tests/qemucapsprobemock.c
1646 --- libvirt-4.6.0.orig/tests/qemucapsprobemock.c        2018-08-02 03:58:35.117820079 +0000
1647 +++ libvirt-4.6.0/tests/qemucapsprobemock.c     2018-08-20 18:00:20.577398013 +0000
1648 @@ -76,7 +76,6 @@ qemuMonitorSend(qemuMonitorPtr mon,
1649          printLineSkipEmpty("\n", stdout);
1650  
1651      printLineSkipEmpty(reformatted, stdout);
1652 -    printLineSkipEmpty("\n", stdout);
1653      VIR_FREE(reformatted);
1654  
1655      return realQemuMonitorSend(mon, msg);
1656 @@ -117,7 +116,6 @@ qemuMonitorJSONIOProcessLine(qemuMonitor
1657              printLineSkipEmpty("\n", stdout);
1658  
1659          printLineSkipEmpty(json, stdout);
1660 -        printLineSkipEmpty("\n", stdout);
1661      }
1662  
1663   cleanup:
1664 diff -urNpa libvirt-4.6.0.orig/tests/qemucommandutiltest.c libvirt-4.6.0/tests/qemucommandutiltest.c
1665 --- libvirt-4.6.0.orig/tests/qemucommandutiltest.c      2018-07-28 13:26:44.484462883 +0000
1666 +++ libvirt-4.6.0/tests/qemucommandutiltest.c   2018-08-20 18:00:20.577398013 +0000
1667 @@ -76,12 +76,7 @@ mymain(void)
1668      int ret = 0;
1669      testQemuCommandBuildObjectFromJSONData data1;
1670  
1671 -#if !WITH_STABLE_ORDERING_JANSSON
1672 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1673 -    return EXIT_AM_SKIP;
1674 -#endif
1675 -
1676 -#if !WITH_JANSSON
1677 +#if !WITH_YAJL
1678      fputs("libvirt not compiled with JSON support, skipping this test\n", stderr);
1679      return EXIT_AM_SKIP;
1680  #endif
1681 diff -urNpa libvirt-4.6.0.orig/tests/qemuhotplugtest.c libvirt-4.6.0/tests/qemuhotplugtest.c
1682 --- libvirt-4.6.0.orig/tests/qemuhotplugtest.c  2018-07-28 13:26:44.484462883 +0000
1683 +++ libvirt-4.6.0/tests/qemuhotplugtest.c       2018-08-20 18:00:20.577398013 +0000
1684 @@ -593,12 +593,7 @@ mymain(void)
1685      struct qemuHotplugTestData data = {0};
1686      struct testQemuHotplugCpuParams cpudata;
1687  
1688 -#if !WITH_STABLE_ORDERING_JANSSON
1689 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1690 -    return EXIT_AM_SKIP;
1691 -#endif
1692 -
1693 -#if !WITH_JANSSON
1694 +#if !WITH_YAJL
1695      fputs("libvirt not compiled with JSON support, skipping this test\n", stderr);
1696      return EXIT_AM_SKIP;
1697  #endif
1698 diff -urNpa libvirt-4.6.0.orig/tests/qemumigparamsdata/empty.json libvirt-4.6.0/tests/qemumigparamsdata/empty.json
1699 --- libvirt-4.6.0.orig/tests/qemumigparamsdata/empty.json       2018-07-28 13:26:44.484462883 +0000
1700 +++ libvirt-4.6.0/tests/qemumigparamsdata/empty.json    2018-08-20 18:00:20.577398013 +0000
1701 @@ -1 +1,3 @@
1702 -{}
1703 +{
1704 +
1705 +}
1706 diff -urNpa libvirt-4.6.0.orig/tests/qemumigparamsdata/unsupported.json libvirt-4.6.0/tests/qemumigparamsdata/unsupported.json
1707 --- libvirt-4.6.0.orig/tests/qemumigparamsdata/unsupported.json 2018-07-28 13:26:44.485462874 +0000
1708 +++ libvirt-4.6.0/tests/qemumigparamsdata/unsupported.json      2018-08-20 18:00:20.577398013 +0000
1709 @@ -1 +1,3 @@
1710 -{}
1711 +{
1712 +
1713 +}
1714 diff -urNpa libvirt-4.6.0.orig/tests/qemumigparamstest.c libvirt-4.6.0/tests/qemumigparamstest.c
1715 --- libvirt-4.6.0.orig/tests/qemumigparamstest.c        2018-07-28 13:26:44.485462874 +0000
1716 +++ libvirt-4.6.0/tests/qemumigparamstest.c     2018-08-20 18:00:20.577398013 +0000
1717 @@ -203,12 +203,7 @@ mymain(void)
1718      virQEMUDriver driver;
1719      int ret = 0;
1720  
1721 -#if !WITH_STABLE_ORDERING_JANSSON
1722 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1723 -    return EXIT_AM_SKIP;
1724 -#endif
1725 -
1726 -#if !WITH_JANSSON
1727 +#if !WITH_YAJL
1728      fputs("libvirt not compiled with JSON support, skipping this test\n", stderr);
1729      return EXIT_AM_SKIP;
1730  #endif
1731 diff -urNpa libvirt-4.6.0.orig/tests/qemumonitorjsontest.c libvirt-4.6.0/tests/qemumonitorjsontest.c
1732 --- libvirt-4.6.0.orig/tests/qemumonitorjsontest.c      2018-07-28 13:26:44.485462874 +0000
1733 +++ libvirt-4.6.0/tests/qemumonitorjsontest.c   2018-08-20 18:00:20.578398013 +0000
1734 @@ -2863,12 +2863,7 @@ mymain(void)
1735      virJSONValuePtr metaschema = NULL;
1736      char *metaschemastr = NULL;
1737  
1738 -#if !WITH_STABLE_ORDERING_JANSSON
1739 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1740 -    return EXIT_AM_SKIP;
1741 -#endif
1742 -
1743 -#if !WITH_JANSSON
1744 +#if !WITH_YAJL
1745      fputs("libvirt not compiled with JSON support, skipping this test\n", stderr);
1746      return EXIT_AM_SKIP;
1747  #endif
1748 diff -urNpa libvirt-4.6.0.orig/tests/virjsontest.c libvirt-4.6.0/tests/virjsontest.c
1749 --- libvirt-4.6.0.orig/tests/virjsontest.c      2018-07-28 13:26:44.505462692 +0000
1750 +++ libvirt-4.6.0/tests/virjsontest.c   2018-08-20 18:00:20.578398013 +0000
1751 @@ -479,11 +479,6 @@ mymain(void)
1752  {
1753      int ret = 0;
1754  
1755 -#if !WITH_STABLE_ORDERING_JANSSON
1756 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1757 -    return EXIT_AM_SKIP;
1758 -#endif
1759 -
1760  #define DO_TEST_FULL(name, cmd, doc, expect, pass) \
1761      do { \
1762          struct testInfo info = { doc, expect, pass }; \
1763 diff -urNpa libvirt-4.6.0.orig/tests/virmacmaptest.c libvirt-4.6.0/tests/virmacmaptest.c
1764 --- libvirt-4.6.0.orig/tests/virmacmaptest.c    2018-07-28 13:26:44.505462692 +0000
1765 +++ libvirt-4.6.0/tests/virmacmaptest.c 2018-08-20 18:00:20.578398013 +0000
1766 @@ -157,11 +157,6 @@ mymain(void)
1767      int ret = 0;
1768      virMacMapPtr mgr = NULL;
1769  
1770 -#if !WITH_STABLE_ORDERING_JANSSON
1771 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1772 -    return EXIT_AM_SKIP;
1773 -#endif
1774 -
1775  #define DO_TEST_BASIC(f, d, ...) \
1776      do { \
1777          const char * const m[] = {__VA_ARGS__, NULL }; \
1778 diff -urNpa libvirt-4.6.0.orig/tests/virmacmaptestdata/empty.json libvirt-4.6.0/tests/virmacmaptestdata/empty.json
1779 --- libvirt-4.6.0.orig/tests/virmacmaptestdata/empty.json       2018-07-28 13:26:44.505462692 +0000
1780 +++ libvirt-4.6.0/tests/virmacmaptestdata/empty.json    2018-08-20 18:00:20.578398013 +0000
1781 @@ -1 +1,3 @@
1782 -[]
1783 +[
1784 +
1785 +]
1786 diff -urNpa libvirt-4.6.0.orig/tests/virmocklibxl.c libvirt-4.6.0/tests/virmocklibxl.c
1787 --- libvirt-4.6.0.orig/tests/virmocklibxl.c     2018-07-28 13:26:44.505462692 +0000
1788 +++ libvirt-4.6.0/tests/virmocklibxl.c  2018-08-20 18:00:20.578398013 +0000
1789 @@ -22,7 +22,7 @@
1790  
1791  #include <config.h>
1792  
1793 -#if defined(WITH_LIBXL) && defined(WITH_JANSSON)
1794 +#if defined(WITH_LIBXL) && defined(WITH_YAJL)
1795  # include "virmock.h"
1796  # include <sys/stat.h>
1797  # include <unistd.h>
1798 @@ -136,4 +136,4 @@ VIR_MOCK_IMPL_RET_ARGS(stat, int,
1799      return real_stat(path, sb);
1800  }
1801  
1802 -#endif /* WITH_LIBXL && WITH_JANSSON */
1803 +#endif /* WITH_LIBXL && WITH_YAJL */
1804 diff -urNpa libvirt-4.6.0.orig/tests/virnetdaemontest.c libvirt-4.6.0/tests/virnetdaemontest.c
1805 --- libvirt-4.6.0.orig/tests/virnetdaemontest.c 2018-07-28 13:26:44.506462683 +0000
1806 +++ libvirt-4.6.0/tests/virnetdaemontest.c      2018-08-20 18:00:20.578398013 +0000
1807 @@ -26,7 +26,7 @@
1808  
1809  #define VIR_FROM_THIS VIR_FROM_RPC
1810  
1811 -#if defined(HAVE_SOCKETPAIR) && defined(WITH_JANSSON)
1812 +#if defined(HAVE_SOCKETPAIR) && defined(WITH_YAJL)
1813  struct testClientPriv {
1814      int magic;
1815  };
1816 @@ -375,11 +375,6 @@ mymain(void)
1817      int ret = 0;
1818      const char *server_names[] = { "testServer0", "testServer1" };
1819  
1820 -# if !WITH_STABLE_ORDERING_JANSSON
1821 -    fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr);
1822 -    return EXIT_AM_SKIP;
1823 -# endif
1824 -
1825      if (virInitialize() < 0 ||
1826          virEventRegisterDefaultImpl() < 0) {
1827          virDispatchError(NULL);
1828 diff -urNpa libvirt-4.6.0.orig/tests/virstoragetest.c libvirt-4.6.0/tests/virstoragetest.c
1829 --- libvirt-4.6.0.orig/tests/virstoragetest.c   2018-07-28 13:26:44.506462683 +0000
1830 +++ libvirt-4.6.0/tests/virstoragetest.c        2018-08-20 18:00:20.578398013 +0000
1831 @@ -1317,7 +1317,7 @@ mymain(void)
1832                         "  <host name='example.org' port='6000'/>\n"
1833                         "</source>\n");
1834  
1835 -#ifdef WITH_JANSSON
1836 +#ifdef WITH_YAJL
1837      TEST_BACKING_PARSE("json:", NULL);
1838      TEST_BACKING_PARSE("json:asdgsdfg", NULL);
1839      TEST_BACKING_PARSE("json:{}", NULL);
1840 @@ -1581,7 +1581,7 @@ mymain(void)
1841                         "<source protocol='vxhs' name='c6718f6b-0401-441d-a8c3-1f0064d75ee0'>\n"
1842                         "  <host name='example.com' port='9999'/>\n"
1843                         "</source>\n");
1844 -#endif /* WITH_JANSSON */
1845 +#endif /* WITH_YAJL */
1846  
1847   cleanup:
1848      /* Final cleanup */