Hello community, here is the log from the commit of package libvirt for openSUSE:Factory checked in at 2018-08-27 13:46:01 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libvirt (Old) and /work/SRC/openSUSE:Factory/.libvirt.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libvirt" Mon Aug 27 13:46:01 2018 rev:264 rq:629267 version:4.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/libvirt/libvirt.changes 2018-08-07 10:50:40.164645890 +0200 +++ /work/SRC/openSUSE:Factory/.libvirt.new/libvirt.changes 2018-08-27 13:46:06.396273738 +0200 @@ -1,0 +2,29 @@ +Tue Aug 14 03:23:24 UTC 2018 - jfeh...@suse.com + +- Revert switch to jansson + boo#1104820 + - Dropped: + temp-build-fix.patch + - Added: + 9ed59012--revert-jansson1.patch, + 54f2b5e3-revert-jansson2.patch, + b56950fd-revert-jansson3.patch, + 6c3d66ac-revert-jansson4.patch, + 8e373e6d-revert-jansson5.patch, + 6f99de31-revert-jansson6.patch, + f204cf51-revert-jansson7.patch, + 5a58b5ed-revert-jansson8.patch, + 63f6e0e9-revert-jansson9.patch, + 8687eba-revert-jansson10.patch, + e96e71d8-revert-jansson11.patch, + d99a8959-revert-jansson12.patch, + 074a7e14-revert-jansson13.patch, + 86db0db9-revert-jansson14.patch + +------------------------------------------------------------------- +Mon Aug 13 18:06:51 UTC 2018 - jfeh...@suse.com + +- spec: don't restart libvirt-guests when updating libvirt-client + bsc#1104662 + +------------------------------------------------------------------- Old: ---- temp-build-fix.patch New: ---- 074a7e14-revert-jansson13.patch 54f2b5e3-revert-jansson2.patch 5a58b5ed-revert-jansson8.patch 63f6e0e9-revert-jansson9.patch 6c3d66ac-revert-jansson4.patch 6f99de31-revert-jansson6.patch 8687eba-revert-jansson10.patch 86db0db9-revert-jansson14.patch 8e373e6d-revert-jansson5.patch 9ed59012--revert-jansson1.patch b56950fd-revert-jansson3.patch d99a8959-revert-jansson12.patch e96e71d8-revert-jansson11.patch f204cf51-revert-jansson7.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libvirt.spec ++++++ --- /var/tmp/diff_new_pack.Krf0pS/_old 2018-08-27 13:46:07.900275892 +0200 +++ /var/tmp/diff_new_pack.Krf0pS/_new 2018-08-27 13:46:07.904275898 +0200 @@ -247,9 +247,9 @@ BuildRequires: perl(XML::XPath) # For pool-build probing for existing pools BuildRequires: libblkid-devel >= 2.17 -BuildRequires: libjansson-devel BuildRequires: libpciaccess0-devel >= 0.10.9 BuildRequires: libudev-devel >= 145 +BuildRequires: libyajl-devel %if %{with_sanlock} BuildRequires: sanlock-devel >= 2.4 %endif @@ -328,6 +328,20 @@ Source99: baselibs.conf Source100: %{name}-rpmlintrc # Upstream patches +Patch0: 9ed59012--revert-jansson1.patch +Patch1: 54f2b5e3-revert-jansson2.patch +Patch2: b56950fd-revert-jansson3.patch +Patch3: 6c3d66ac-revert-jansson4.patch +Patch4: 8e373e6d-revert-jansson5.patch +Patch5: 6f99de31-revert-jansson6.patch +Patch6: f204cf51-revert-jansson7.patch +Patch7: 5a58b5ed-revert-jansson8.patch +Patch8: 63f6e0e9-revert-jansson9.patch +Patch9: 8687eba-revert-jansson10.patch +Patch10: e96e71d8-revert-jansson11.patch +Patch11: d99a8959-revert-jansson12.patch +Patch12: 074a7e14-revert-jansson13.patch +Patch13: 86db0db9-revert-jansson14.patch # Patches pending upstream review Patch100: libxl-dom-reset.patch Patch101: network-don-t-use-dhcp-authoritative-on-static-netwo.patch @@ -341,7 +355,6 @@ Patch156: 0001-Extract-stats-functions-from-the-qemu-driver.patch Patch157: 0002-lxc-implement-connectGetAllDomainStats.patch Patch158: 0001-libxl-add-support-for-BlockResize-API.patch -Patch159: temp-build-fix.patch # Our patches Patch200: suse-libvirtd-disable-tls.patch Patch201: suse-libvirtd-sysconfig-settings.patch @@ -839,8 +852,6 @@ # Needed by virt-pki-validate script. Requires: cyrus-sasl Requires: gnutls -# We dlopen(libjansson.so.4), so need an explicit dep -Requires: libjansson4 %if %{with_bash_completion} Requires: %{name}-bash-completion = %{version}-%{release} %endif @@ -931,6 +942,20 @@ %prep %setup -q +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 %patch100 -p1 %patch101 -p1 %patch150 -p1 @@ -942,7 +967,6 @@ %patch156 -p1 %patch157 -p1 %patch158 -p1 -%patch159 -p1 %patch200 -p1 %patch201 -p1 %patch202 -p1 @@ -1124,7 +1148,7 @@ %{?arg_apparmor} \ %{?arg_apparmor_profiles} \ --with-udev \ - --with-jansson \ + --with-yajl \ %{?arg_sanlock} \ --with-libpcap \ --with-macvtap \ @@ -1371,7 +1395,7 @@ fi %postun client -%service_del_postun libvirt-guests.service +%service_del_postun -n libvirt-guests.service %post libs -p /sbin/ldconfig ++++++ 074a7e14-revert-jansson13.patch ++++++ commit 074a7e14780e6aff78c7305c7dcad059a998c08a Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:40:25 2018 +0200 Revert "build: undef WITH_JANSSON for SETUID_RPC_CLIENT" This reverts commit 93fdc9e0b0cbb2eec32745a868ac4633f0912ad5. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/config-post.h =================================================================== --- libvirt-4.6.0.orig/config-post.h +++ libvirt-4.6.0/config-post.h @@ -36,7 +36,6 @@ # undef WITH_DEVMAPPER # undef WITH_DTRACE_PROBES # undef WITH_GNUTLS -# undef WITH_JANSSON # undef WITH_LIBSSH # undef WITH_MACVTAP # undef WITH_NUMACTL ++++++ 54f2b5e3-revert-jansson2.patch ++++++ commit 54f2b5e330aa20c9745b2545fc88973539015b98 Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:38:46 2018 +0200 Revert "util: jsoncompat: Stub out virJSONInitialize when compiling without jansson" This reverts commit 9e44c2db8ad94d3c20acc1d081538c280af198b4. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/src/util/virjsoncompat.c =================================================================== --- libvirt-4.6.0.orig/src/util/virjsoncompat.c +++ libvirt-4.6.0/src/util/virjsoncompat.c @@ -271,15 +271,4 @@ json_true_impl(void) return json_true_ptr(); } - -#else /* !WITH_JANSSON */ - - -int -virJSONInitialize(void) -{ - return 0; -} - - -#endif /* !WITH_JANSSON */ +#endif /* WITH_JANSSON */ ++++++ 5a58b5ed-revert-jansson8.patch ++++++ commit 5a58b5ed6803e71e32e5d6f8c6e3b68874d085fb Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:39:48 2018 +0200 Revert "build: switch --with-qemu default from yes to check" This reverts commit c5ae8e0c2b4b6bb3c667cfadaf65a66c3f4f3d85. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/m4/virt-driver-qemu.m4 =================================================================== --- libvirt-4.6.0.orig/m4/virt-driver-qemu.m4 +++ libvirt-4.6.0/m4/virt-driver-qemu.m4 @@ -18,7 +18,7 @@ dnl <http://www.gnu.org/licenses/>. dnl AC_DEFUN([LIBVIRT_DRIVER_ARG_QEMU], [ - LIBVIRT_ARG_WITH_FEATURE([QEMU], [QEMU/KVM], [check]) + LIBVIRT_ARG_WITH_FEATURE([QEMU], [QEMU/KVM], [yes]) LIBVIRT_ARG_WITH([QEMU_USER], [username to run QEMU system instance as], ['platform dependent']) LIBVIRT_ARG_WITH([QEMU_GROUP], [groupname to run QEMU system instance as], @@ -26,10 +26,6 @@ AC_DEFUN([LIBVIRT_DRIVER_ARG_QEMU], [ ]) AC_DEFUN([LIBVIRT_DRIVER_CHECK_QEMU], [ - AC_REQUIRE([LIBVIRT_CHECK_JANSSON]) - if test "$with_qemu" = "check"; then - with_qemu=$with_jansson - fi if test "$with_qemu" = "yes" ; then AC_DEFINE_UNQUOTED([WITH_QEMU], 1, [whether QEMU driver is enabled]) fi ++++++ 63f6e0e9-revert-jansson9.patch ++++++ commit 63f6e0e95036a0634ee8147ee7a463c4066fa720 Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:39:56 2018 +0200 Revert "Remove virJSONValueNewStringLen" This reverts commit 8f802c6d8659beb9eb3cab96ba2553e251728337. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/src/libvirt_private.syms =================================================================== --- libvirt-4.6.0.orig/src/libvirt_private.syms +++ libvirt-4.6.0/src/libvirt_private.syms @@ -2098,6 +2098,7 @@ virJSONValueNewNumberUint; virJSONValueNewNumberUlong; virJSONValueNewObject; virJSONValueNewString; +virJSONValueNewStringLen; virJSONValueObjectAdd; virJSONValueObjectAddVArgs; virJSONValueObjectAppend; Index: libvirt-4.6.0/src/util/virjson.c =================================================================== --- libvirt-4.6.0.orig/src/util/virjson.c +++ libvirt-4.6.0/src/util/virjson.c @@ -420,6 +420,28 @@ virJSONValueNewString(const char *data) } +virJSONValuePtr +virJSONValueNewStringLen(const char *data, + size_t length) +{ + virJSONValuePtr val; + + if (!data) + return virJSONValueNewNull(); + + if (VIR_ALLOC(val) < 0) + return NULL; + + val->type = VIR_JSON_TYPE_STRING; + if (VIR_STRNDUP(val->data.string, data, length) < 0) { + VIR_FREE(val); + return NULL; + } + + return val; +} + + static virJSONValuePtr virJSONValueNewNumber(const char *data) { Index: libvirt-4.6.0/src/util/virjson.h =================================================================== --- libvirt-4.6.0.orig/src/util/virjson.h +++ libvirt-4.6.0/src/util/virjson.h @@ -59,6 +59,7 @@ int virJSONValueObjectAddVArgs(virJSONVa virJSONValuePtr virJSONValueNewString(const char *data); +virJSONValuePtr virJSONValueNewStringLen(const char *data, size_t length); virJSONValuePtr virJSONValueNewNumberInt(int data); virJSONValuePtr virJSONValueNewNumberUint(unsigned int data); virJSONValuePtr virJSONValueNewNumberLong(long long data); ++++++ 6c3d66ac-revert-jansson4.patch ++++++ commit 6c3d66ac7409579752765c12e65adccec30e24fc Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:39:16 2018 +0200 Revert "util: avoid symbol clash between json libraries" This reverts commit ce3c6ef6843f98d81be5423ece11fad79eaab920. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/libvirt.spec.in =================================================================== --- libvirt-4.6.0.orig/libvirt.spec.in +++ libvirt-4.6.0/libvirt.spec.in @@ -898,8 +898,6 @@ Requires: ncurses Requires: gettext # Needed by virt-pki-validate script. Requires: gnutls-utils -# We dlopen(libjansson.so.4), so need an explicit dep -Requires: jansson %if %{with_bash_completion} Requires: %{name}-bash-completion = %{version}-%{release} %endif Index: libvirt-4.6.0/src/Makefile.am =================================================================== --- libvirt-4.6.0.orig/src/Makefile.am +++ libvirt-4.6.0/src/Makefile.am @@ -552,6 +552,7 @@ libvirt_admin_la_CFLAGS += \ libvirt_admin_la_LIBADD += \ $(CAPNG_LIBS) \ + $(JANSSON_LIBS) \ $(DEVMAPPER_LIBS) \ $(LIBXML_LIBS) \ $(SSH2_LIBS) \ @@ -689,7 +690,6 @@ libvirt_setuid_rpc_client_la_SOURCES = \ util/virhashcode.c \ util/virhostcpu.c \ util/virjson.c \ - util/virjsoncompat.c \ util/virlog.c \ util/virobject.c \ util/virpidfile.c \ @@ -961,8 +961,6 @@ libvirt_nss_la_SOURCES = \ util/virhashcode.h \ util/virjson.c \ util/virjson.h \ - util/virjsoncompat.c \ - util/virjsoncompat.h \ util/virkmod.c \ util/virkmod.h \ util/virlease.c \ @@ -1001,6 +999,10 @@ libvirt_nss_la_CFLAGS = \ libvirt_nss_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(NULL) + +libvirt_nss_la_LIBADD = \ + $(JANSSON_LIBS) \ + $(NULL) endif WITH_NSS Index: libvirt-4.6.0/src/util/Makefile.inc.am =================================================================== --- libvirt-4.6.0.orig/src/util/Makefile.inc.am +++ libvirt-4.6.0/src/util/Makefile.inc.am @@ -86,8 +86,6 @@ UTIL_SOURCES = \ util/viriscsi.h \ util/virjson.c \ util/virjson.h \ - util/virjsoncompat.c \ - util/virjsoncompat.h \ util/virkeycode.c \ util/virkeycode.h \ util/virkeyfile.c \ @@ -266,6 +264,7 @@ libvirt_util_la_CFLAGS = \ $(NULL) libvirt_util_la_LIBADD = \ $(CAPNG_LIBS) \ + $(JANSSON_LIBS) \ $(LIBNL_LIBS) \ $(THREAD_LIBS) \ $(AUDIT_LIBS) \ Index: libvirt-4.6.0/src/util/virjson.c =================================================================== --- libvirt-4.6.0.orig/src/util/virjson.c +++ libvirt-4.6.0/src/util/virjson.c @@ -1437,8 +1437,7 @@ virJSONValueCopy(const virJSONValue *in) #if WITH_JANSSON - -# include "virjsoncompat.h" +# include <jansson.h> static virJSONValuePtr virJSONValueFromJansson(json_t *json) @@ -1525,9 +1524,6 @@ virJSONValueFromString(const char *jsons size_t flags = JSON_REJECT_DUPLICATES | JSON_DECODE_ANY; - if (virJSONInitialize() < 0) - return NULL; - if (!(json = json_loads(jsonstring, flags, &error))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse JSON %d:%d: %s"), @@ -1634,9 +1630,6 @@ virJSONValueToString(virJSONValuePtr obj json_t *json; char *str = NULL; - if (virJSONInitialize() < 0) - return NULL; - if (pretty) flags |= JSON_INDENT(2); else Index: libvirt-4.6.0/src/util/virjsoncompat.c =================================================================== --- libvirt-4.6.0.orig/src/util/virjsoncompat.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * virjsoncompat.c: JSON object parsing/formatting - * - * Copyright (C) 2018 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include <config.h> - -#include "virthread.h" -#include "virerror.h" -#define VIR_JSON_COMPAT_IMPL -#include "virjsoncompat.h" - -#define VIR_FROM_THIS VIR_FROM_NONE - -#if WITH_JANSSON - -# include <dlfcn.h> - -json_t *(*json_array_ptr)(void); -int (*json_array_append_new_ptr)(json_t *array, json_t *value); -json_t *(*json_array_get_ptr)(const json_t *array, size_t index); -size_t (*json_array_size_ptr)(const json_t *array); -void (*json_delete_ptr)(json_t *json); -char *(*json_dumps_ptr)(const json_t *json, size_t flags); -json_t *(*json_false_ptr)(void); -json_t *(*json_integer_ptr)(json_int_t value); -json_int_t (*json_integer_value_ptr)(const json_t *integer); -json_t *(*json_loads_ptr)(const char *input, size_t flags, json_error_t *error); -json_t *(*json_null_ptr)(void); -json_t *(*json_object_ptr)(void); -void *(*json_object_iter_ptr)(json_t *object); -const char *(*json_object_iter_key_ptr)(void *iter); -void *(*json_object_iter_next_ptr)(json_t *object, void *iter); -json_t *(*json_object_iter_value_ptr)(void *iter); -void *(*json_object_key_to_iter_ptr)(const char *key); -int (*json_object_set_new_ptr)(json_t *object, const char *key, json_t *value); -json_t *(*json_real_ptr)(double value); -double (*json_real_value_ptr)(const json_t *real); -json_t *(*json_string_ptr)(const char *value); -const char *(*json_string_value_ptr)(const json_t *string); -json_t *(*json_true_ptr)(void); - - -static int -virJSONJanssonOnceInit(void) -{ - void *handle = dlopen("libjansson.so.4", RTLD_LAZY|RTLD_LOCAL|RTLD_NODELETE); - if (!handle) { - virReportError(VIR_ERR_NO_SUPPORT, - _("libjansson.so.4 JSON library not available: %s"), dlerror()); - return -1; - } - -# define LOAD(name) \ - do { \ - if (!(name ## _ptr = dlsym(handle, #name))) { \ - virReportError(VIR_ERR_NO_SUPPORT, \ - _("missing symbol '%s' in libjansson.so.4: %s"), #name, dlerror()); \ - return -1; \ - } \ - } while (0) - - LOAD(json_array); - LOAD(json_array_append_new); - LOAD(json_array_get); - LOAD(json_array_size); - LOAD(json_delete); - LOAD(json_dumps); - LOAD(json_false); - LOAD(json_integer); - LOAD(json_integer_value); - LOAD(json_loads); - LOAD(json_null); - LOAD(json_object); - LOAD(json_object_iter); - LOAD(json_object_iter_key); - LOAD(json_object_iter_next); - LOAD(json_object_iter_value); - LOAD(json_object_key_to_iter); - LOAD(json_object_set_new); - LOAD(json_real); - LOAD(json_real_value); - LOAD(json_string); - LOAD(json_string_value); - LOAD(json_true); - - return 0; -} - -VIR_ONCE_GLOBAL_INIT(virJSONJansson); - -int -virJSONInitialize(void) -{ - return virJSONJanssonInitialize(); -} - -json_t * -json_array_impl(void) -{ - return json_array_ptr(); -} - - -int -json_array_append_new_impl(json_t *array, json_t *value) -{ - return json_array_append_new_ptr(array, value); -} - - -json_t * -json_array_get_impl(const json_t *array, size_t index) -{ - return json_array_get_ptr(array, index); -} - - -size_t -json_array_size_impl(const json_t *array) -{ - return json_array_size_ptr(array); -} - - -void -json_delete_impl(json_t *json) -{ - return json_delete_ptr(json); -} - - -char * -json_dumps_impl(const json_t *json, size_t flags) -{ - return json_dumps_ptr(json, flags); -} - - -json_t * -json_false_impl(void) -{ - return json_false_ptr(); -} - - -json_t * -json_integer_impl(json_int_t value) -{ - return json_integer_ptr(value); -} - - -json_int_t -json_integer_value_impl(const json_t *integer) -{ - return json_integer_value_ptr(integer); -} - - -json_t * -json_loads_impl(const char *input, size_t flags, json_error_t *error) -{ - return json_loads_ptr(input, flags, error); -} - - -json_t * -json_null_impl(void) -{ - return json_null_ptr(); -} - - -json_t * -json_object_impl(void) -{ - return json_object_ptr(); -} - - -void * -json_object_iter_impl(json_t *object) -{ - return json_object_iter_ptr(object); -} - - -const char * -json_object_iter_key_impl(void *iter) -{ - return json_object_iter_key_ptr(iter); -} - - -void * -json_object_iter_next_impl(json_t *object, void *iter) -{ - return json_object_iter_next_ptr(object, iter); -} - - -json_t * -json_object_iter_value_impl(void *iter) -{ - return json_object_iter_value_ptr(iter); -} - - -void * -json_object_key_to_iter_impl(const char *key) -{ - return json_object_key_to_iter_ptr(key); -} - - -int -json_object_set_new_impl(json_t *object, const char *key, json_t *value) -{ - return json_object_set_new_ptr(object, key, value); -} - - -json_t * -json_real_impl(double value) -{ - return json_real_ptr(value); -} - - -double -json_real_value_impl(const json_t *real) -{ - return json_real_value_ptr(real); -} - - -json_t * -json_string_impl(const char *value) -{ - return json_string_ptr(value); -} - - -const char * -json_string_value_impl(const json_t *string) -{ - return json_string_value_ptr(string); -} - - -json_t * -json_true_impl(void) -{ - return json_true_ptr(); -} - -#endif /* WITH_JANSSON */ Index: libvirt-4.6.0/src/util/virjsoncompat.h =================================================================== --- libvirt-4.6.0.orig/src/util/virjsoncompat.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * virjsoncompat.h: JSON object parsing/formatting - * - * Copyright (C) 2018 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - - -#ifndef __VIR_JSON_COMPAT_H_ -# define __VIR_JSON_COMPAT_H_ - -# if WITH_JANSSON -# ifndef VIR_JSON_COMPAT_IMPL - -# define json_array json_array_impl -# define json_array_append_new json_array_append_new_impl -# define json_array_get json_array_get_impl -# define json_array_size json_array_size_impl -# define json_delete json_delete_impl -# define json_dumps json_dumps_impl -# define json_false json_false_impl -# define json_integer json_integer_impl -# define json_integer_value json_integer_value_impl -# define json_loads json_loads_impl -# define json_null json_null_impl -# define json_object json_object_impl -# define json_object_iter json_object_iter_impl -# define json_object_iter_key json_object_iter_key_impl -# define json_object_iter_next json_object_iter_next_impl -# define json_object_iter_value json_object_iter_value_impl -# define json_object_key_to_iter json_object_key_to_iter_impl -# define json_object_set_new json_object_set_new_impl -# define json_real json_real_impl -# define json_real_value json_real_value_impl -# define json_string json_string_impl -# define json_string_value json_string_value_impl -# define json_true json_true_impl - -# endif /* ! VIR_JSON_COMPAT_IMPL */ - -# include <jansson.h> - -# ifdef VIR_JSON_COMPAT_IMPL - -json_t *json_array_impl(void); -int json_array_append_new_impl(json_t *array, json_t *value); -json_t *json_array_get_impl(const json_t *array, size_t index); -size_t json_array_size_impl(const json_t *array); -void json_delete_impl(json_t *json); -char *json_dumps_impl(const json_t *json, size_t flags); -json_t *json_false_impl(void); -json_t *json_integer_impl(json_int_t value); -json_int_t json_integer_value_impl(const json_t *integer); -json_t *json_loads_impl(const char *input, size_t flags, json_error_t *error); -json_t *json_null_impl(void); -json_t *json_object_impl(void); -void *json_object_iter_impl(json_t *object); -const char *json_object_iter_key_impl(void *iter); -void *json_object_iter_next_impl(json_t *object, void *iter); -json_t *json_object_iter_value_impl(void *iter); -void *json_object_key_to_iter_impl(const char *key); -int json_object_set_new_impl(json_t *object, const char *key, json_t *value); -json_t *json_real_impl(double value); -double json_real_value_impl(const json_t *real); -json_t *json_string_impl(const char *value); -const char *json_string_value_impl(const json_t *string); -json_t *json_true_impl(void); - -# endif /* VIR_JSON_COMPAT_IMPL */ -# endif /* WITH_JANSSON */ - -int virJSONInitialize(void); - -#endif /* __VIR_JSON_COMPAT_H_ */ ++++++ 6f99de31-revert-jansson6.patch ++++++ commit 6f99de314855296d52cdf0badcab5b12213f2ca4 Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:39:33 2018 +0200 Revert "m4: Introduce STABLE_ORDERING_JANSSON" This reverts commit 4dd60540007042bfc0087a67f57f3e9f3311a84a. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/m4/virt-jansson.m4 =================================================================== --- libvirt-4.6.0.orig/m4/virt-jansson.m4 +++ libvirt-4.6.0/m4/virt-jansson.m4 @@ -22,9 +22,6 @@ AC_DEFUN([LIBVIRT_ARG_JANSSON],[ AC_DEFUN([LIBVIRT_CHECK_JANSSON],[ dnl Jansson http://www.digip.org/jansson/ LIBVIRT_CHECK_PKG([JANSSON], [jansson], [2.5]) - dnl Older versions of Jansson did not preserve the order of object keys - dnl use this check to guard the tests that are sensitive to this - LIBVIRT_CHECK_PKG([STABLE_ORDERING_JANSSON], [jansson], [2.8], [true]) ]) AC_DEFUN([LIBVIRT_RESULT_JANSSON],[ Index: libvirt-4.6.0/tests/qemublocktest.c =================================================================== --- libvirt-4.6.0.orig/tests/qemublocktest.c +++ libvirt-4.6.0/tests/qemublocktest.c @@ -337,11 +337,6 @@ mymain(void) char *capslatest_x86_64 = NULL; virQEMUCapsPtr caps_x86_64 = NULL; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -#endif - if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; Index: libvirt-4.6.0/tests/qemucapabilitiestest.c =================================================================== --- libvirt-4.6.0.orig/tests/qemucapabilitiestest.c +++ libvirt-4.6.0/tests/qemucapabilitiestest.c @@ -141,11 +141,6 @@ mymain(void) int ret = 0; testQemuData data; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -#endif - #if !WITH_JANSSON fputs("libvirt not compiled with JSON support, skipping this test\n", stderr); return EXIT_AM_SKIP; Index: libvirt-4.6.0/tests/qemucommandutiltest.c =================================================================== --- libvirt-4.6.0.orig/tests/qemucommandutiltest.c +++ libvirt-4.6.0/tests/qemucommandutiltest.c @@ -76,11 +76,6 @@ mymain(void) int ret = 0; testQemuCommandBuildObjectFromJSONData data1; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -#endif - #if !WITH_JANSSON fputs("libvirt not compiled with JSON support, skipping this test\n", stderr); return EXIT_AM_SKIP; Index: libvirt-4.6.0/tests/qemuhotplugtest.c =================================================================== --- libvirt-4.6.0.orig/tests/qemuhotplugtest.c +++ libvirt-4.6.0/tests/qemuhotplugtest.c @@ -593,11 +593,6 @@ mymain(void) struct qemuHotplugTestData data = {0}; struct testQemuHotplugCpuParams cpudata; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -#endif - #if !WITH_JANSSON fputs("libvirt not compiled with JSON support, skipping this test\n", stderr); return EXIT_AM_SKIP; Index: libvirt-4.6.0/tests/qemumigparamstest.c =================================================================== --- libvirt-4.6.0.orig/tests/qemumigparamstest.c +++ libvirt-4.6.0/tests/qemumigparamstest.c @@ -203,11 +203,6 @@ mymain(void) virQEMUDriver driver; int ret = 0; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -#endif - #if !WITH_JANSSON fputs("libvirt not compiled with JSON support, skipping this test\n", stderr); return EXIT_AM_SKIP; Index: libvirt-4.6.0/tests/qemumonitorjsontest.c =================================================================== --- libvirt-4.6.0.orig/tests/qemumonitorjsontest.c +++ libvirt-4.6.0/tests/qemumonitorjsontest.c @@ -2863,11 +2863,6 @@ mymain(void) virJSONValuePtr metaschema = NULL; char *metaschemastr = NULL; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -#endif - #if !WITH_JANSSON fputs("libvirt not compiled with JSON support, skipping this test\n", stderr); return EXIT_AM_SKIP; Index: libvirt-4.6.0/tests/virjsontest.c =================================================================== --- libvirt-4.6.0.orig/tests/virjsontest.c +++ libvirt-4.6.0/tests/virjsontest.c @@ -479,11 +479,6 @@ mymain(void) { int ret = 0; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -#endif - #define DO_TEST_FULL(name, cmd, doc, expect, pass) \ do { \ struct testInfo info = { doc, expect, pass }; \ Index: libvirt-4.6.0/tests/virmacmaptest.c =================================================================== --- libvirt-4.6.0.orig/tests/virmacmaptest.c +++ libvirt-4.6.0/tests/virmacmaptest.c @@ -157,11 +157,6 @@ mymain(void) int ret = 0; virMacMapPtr mgr = NULL; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -#endif - #define DO_TEST_BASIC(f, d, ...) \ do { \ const char * const m[] = {__VA_ARGS__, NULL }; \ Index: libvirt-4.6.0/tests/virnetdaemontest.c =================================================================== --- libvirt-4.6.0.orig/tests/virnetdaemontest.c +++ libvirt-4.6.0/tests/virnetdaemontest.c @@ -375,11 +375,6 @@ mymain(void) int ret = 0; const char *server_names[] = { "testServer0", "testServer1" }; -# if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); - return EXIT_AM_SKIP; -# endif - if (virInitialize() < 0 || virEventRegisterDefaultImpl() < 0) { virDispatchError(NULL); ++++++ 8687eba-revert-jansson10.patch ++++++ commit 8687eba5ca9a78b3a74a7c4e162d80633b8d877b Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:40:02 2018 +0200 Revert "build: remove references to WITH_YAJL for SETUID_RPC_CLIENT" This reverts commit 1caf8441604b58e4a89aa2c09975b8346928c52a. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/config-post.h =================================================================== --- libvirt-4.6.0.orig/config-post.h +++ libvirt-4.6.0/config-post.h @@ -44,6 +44,8 @@ # undef WITH_SSH2 # undef WITH_SYSTEMD_DAEMON # undef WITH_VIRTUALPORT +# undef WITH_YAJL +# undef WITH_YAJL2 #endif /* ++++++ 86db0db9-revert-jansson14.patch ++++++ commit 86db0db979c39df278f03dbf3b4239c873ddb637 Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:41:14 2018 +0200 Revert "build: add --with-jansson" This reverts commit 12b34f094e2f1c7f414f4bb8f880a9d65c8fcd85. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Conflicts: configure.ac: Commit 8aa85e0b introduced LIBVIRT_*_LIBISCSI macros. Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/configure.ac =================================================================== --- libvirt-4.6.0.orig/configure.ac +++ libvirt-4.6.0/configure.ac @@ -250,7 +250,6 @@ LIBVIRT_ARG_FIREWALLD LIBVIRT_ARG_FUSE LIBVIRT_ARG_GLUSTER LIBVIRT_ARG_HAL -LIBVIRT_ARG_JANSSON LIBVIRT_ARG_LIBPCAP LIBVIRT_ARG_LIBSSH LIBVIRT_ARG_LIBXML @@ -291,7 +290,6 @@ LIBVIRT_CHECK_FUSE LIBVIRT_CHECK_GLUSTER LIBVIRT_CHECK_GNUTLS LIBVIRT_CHECK_HAL -LIBVIRT_CHECK_JANSSON LIBVIRT_CHECK_LIBNL LIBVIRT_CHECK_LIBPARTED LIBVIRT_CHECK_LIBPCAP @@ -972,7 +970,6 @@ LIBVIRT_RESULT_FUSE LIBVIRT_RESULT_GLUSTER LIBVIRT_RESULT_GNUTLS LIBVIRT_RESULT_HAL -LIBVIRT_RESULT_JANSSON LIBVIRT_RESULT_LIBNL LIBVIRT_RESULT_LIBPCAP LIBVIRT_RESULT_LIBSSH Index: libvirt-4.6.0/m4/virt-jansson.m4 =================================================================== --- libvirt-4.6.0.orig/m4/virt-jansson.m4 +++ /dev/null @@ -1,29 +0,0 @@ -dnl The jansson library -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl <http://www.gnu.org/licenses/>. -dnl - -AC_DEFUN([LIBVIRT_ARG_JANSSON],[ - LIBVIRT_ARG_WITH_FEATURE([JANSSON], [jansson], [check]) -]) - -AC_DEFUN([LIBVIRT_CHECK_JANSSON],[ - dnl Jansson http://www.digip.org/jansson/ - LIBVIRT_CHECK_PKG([JANSSON], [jansson], [2.5]) -]) - -AC_DEFUN([LIBVIRT_RESULT_JANSSON],[ - LIBVIRT_RESULT_LIB([JANSSON]) -]) ++++++ 8e373e6d-revert-jansson5.patch ++++++ commit 8e373e6d80afa3b212464b8b1a9faa36ee684472 Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:39:25 2018 +0200 Revert "tests: also skip qemuagenttest with old jansson" This reverts commit c31146685f5c8558ff88d52d03a68533c9220feb. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/tests/qemuagenttest.c =================================================================== --- libvirt-4.6.0.orig/tests/qemuagenttest.c +++ libvirt-4.6.0/tests/qemuagenttest.c @@ -907,8 +907,8 @@ mymain(void) { int ret = 0; -#if !WITH_STABLE_ORDERING_JANSSON - fputs("libvirt not compiled with recent enough Jansson, skipping this test\n", stderr); +#if !WITH_JANSSON + fputs("libvirt not compiled with JSON support, skipping this test\n", stderr); return EXIT_AM_SKIP; #endif ++++++ 9ed59012--revert-jansson1.patch ++++++ commit 9ed59012d3ccdf8365f5e8119959017849bc89fd Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:38:38 2018 +0200 Revert "remote: daemon: Make sure that JSON symbols are properly loaded at startup" This reverts commit 3251fc9c9b9639c3fec3181530599415523d671a. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/src/libvirt_private.syms =================================================================== --- libvirt-4.6.0.orig/src/libvirt_private.syms +++ libvirt-4.6.0/src/libvirt_private.syms @@ -2135,10 +2135,6 @@ virJSONValueObjectStealObject; virJSONValueToString; -# util/virjsoncompat.h -virJSONInitialize; - - # util/virkeycode.h virKeycodeSetTypeFromString; virKeycodeSetTypeToString; Index: libvirt-4.6.0/src/remote/remote_daemon.c =================================================================== --- libvirt-4.6.0.orig/src/remote/remote_daemon.c +++ libvirt-4.6.0/src/remote/remote_daemon.c @@ -59,7 +59,6 @@ #include "virutil.h" #include "virgettext.h" #include "util/virnetdevopenvswitch.h" -#include "virjsoncompat.h" #include "driver.h" @@ -1184,9 +1183,6 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } - if (virJSONInitialize() < 0) - exit(EXIT_FAILURE); - daemonSetupNetDevOpenvswitch(config); if (daemonSetupAccessManager(config) < 0) { ++++++ b56950fd-revert-jansson3.patch ++++++ commit b56950fd277c0e31cbdf3a0e5b3c944f9857789a Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:39:09 2018 +0200 Revert "tests: qemucapsprobe: Fix output after switching to jansson" This reverts commit 397447f80588438545994a86883792a5999cad15. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/tests/qemucapsprobemock.c =================================================================== --- libvirt-4.6.0.orig/tests/qemucapsprobemock.c +++ libvirt-4.6.0/tests/qemucapsprobemock.c @@ -76,7 +76,6 @@ qemuMonitorSend(qemuMonitorPtr mon, printLineSkipEmpty("\n", stdout); printLineSkipEmpty(reformatted, stdout); - printLineSkipEmpty("\n", stdout); VIR_FREE(reformatted); return realQemuMonitorSend(mon, msg); @@ -117,7 +116,6 @@ qemuMonitorJSONIOProcessLine(qemuMonitor printLineSkipEmpty("\n", stdout); printLineSkipEmpty(json, stdout); - printLineSkipEmpty("\n", stdout); } cleanup: ++++++ d99a8959-revert-jansson12.patch ++++++ ++++ 712 lines (skipped) ++++++ e96e71d8-revert-jansson11.patch ++++++ commit e96e71d8d07eff9324f4df059dfcebaf0fe2eda9 Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:40:11 2018 +0200 Revert "Remove functions using yajl" This reverts commit bf114decb34f21cd225ead6dc4d929d35a8c5fe5. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/src/util/virjson.c =================================================================== --- libvirt-4.6.0.orig/src/util/virjson.c +++ libvirt-4.6.0/src/util/virjson.c @@ -29,6 +29,22 @@ #include "virstring.h" #include "virutil.h" +#if WITH_YAJL +# include <yajl/yajl_gen.h> +# include <yajl/yajl_parse.h> + +# ifdef WITH_YAJL2 +# define yajl_size_t size_t +# define VIR_YAJL_STATUS_OK(status) ((status) == yajl_status_ok) +# else +# define yajl_size_t unsigned int +# define yajl_complete_parse yajl_parse_complete +# define VIR_YAJL_STATUS_OK(status) \ + ((status) == yajl_status_ok || (status) == yajl_status_insufficient_data) +# endif + +#endif + /* XXX fixme */ #define VIR_FROM_THIS VIR_FROM_NONE @@ -72,6 +88,23 @@ struct _virJSONValue { }; +typedef struct _virJSONParserState virJSONParserState; +typedef virJSONParserState *virJSONParserStatePtr; +struct _virJSONParserState { + virJSONValuePtr value; + char *key; +}; + +typedef struct _virJSONParser virJSONParser; +typedef virJSONParser *virJSONParserPtr; +struct _virJSONParser { + virJSONValuePtr head; + virJSONParserStatePtr state; + size_t nstate; + int wrap; +}; + + virJSONType virJSONValueGetType(const virJSONValue *value) { @@ -1458,7 +1491,501 @@ virJSONValueCopy(const virJSONValue *in) } -#if WITH_JANSSON +#if WITH_YAJL +static int +virJSONParserInsertValue(virJSONParserPtr parser, + virJSONValuePtr value) +{ + if (!parser->head) { + parser->head = value; + } else { + virJSONParserStatePtr state; + if (!parser->nstate) { + VIR_DEBUG("got a value to insert without a container"); + return -1; + } + + state = &parser->state[parser->nstate-1]; + + switch (state->value->type) { + case VIR_JSON_TYPE_OBJECT: { + if (!state->key) { + VIR_DEBUG("missing key when inserting object value"); + return -1; + } + + if (virJSONValueObjectAppend(state->value, + state->key, + value) < 0) + return -1; + + VIR_FREE(state->key); + } break; + + case VIR_JSON_TYPE_ARRAY: { + if (state->key) { + VIR_DEBUG("unexpected key when inserting array value"); + return -1; + } + + if (virJSONValueArrayAppend(state->value, + value) < 0) + return -1; + } break; + + default: + VIR_DEBUG("unexpected value type, not a container"); + return -1; + } + } + + return 0; +} + + +static int +virJSONParserHandleNull(void *ctx) +{ + virJSONParserPtr parser = ctx; + virJSONValuePtr value = virJSONValueNewNull(); + + VIR_DEBUG("parser=%p", parser); + + if (!value) + return 0; + + if (virJSONParserInsertValue(parser, value) < 0) { + virJSONValueFree(value); + return 0; + } + + return 1; +} + + +static int +virJSONParserHandleBoolean(void *ctx, + int boolean_) +{ + virJSONParserPtr parser = ctx; + virJSONValuePtr value = virJSONValueNewBoolean(boolean_); + + VIR_DEBUG("parser=%p boolean=%d", parser, boolean_); + + if (!value) + return 0; + + if (virJSONParserInsertValue(parser, value) < 0) { + virJSONValueFree(value); + return 0; + } + + return 1; +} + + +static int +virJSONParserHandleNumber(void *ctx, + const char *s, + yajl_size_t l) +{ + virJSONParserPtr parser = ctx; + char *str; + virJSONValuePtr value; + + if (VIR_STRNDUP(str, s, l) < 0) + return -1; + value = virJSONValueNewNumber(str); + VIR_FREE(str); + + VIR_DEBUG("parser=%p str=%s", parser, str); + + if (!value) + return 0; + + if (virJSONParserInsertValue(parser, value) < 0) { + virJSONValueFree(value); + return 0; + } + + return 1; +} + + +static int +virJSONParserHandleString(void *ctx, + const unsigned char *stringVal, + yajl_size_t stringLen) +{ + virJSONParserPtr parser = ctx; + virJSONValuePtr value = virJSONValueNewStringLen((const char *)stringVal, + stringLen); + + VIR_DEBUG("parser=%p str=%p", parser, (const char *)stringVal); + + if (!value) + return 0; + + if (virJSONParserInsertValue(parser, value) < 0) { + virJSONValueFree(value); + return 0; + } + + return 1; +} + + +static int +virJSONParserHandleMapKey(void *ctx, + const unsigned char *stringVal, + yajl_size_t stringLen) +{ + virJSONParserPtr parser = ctx; + virJSONParserStatePtr state; + + VIR_DEBUG("parser=%p key=%p", parser, (const char *)stringVal); + + if (!parser->nstate) + return 0; + + state = &parser->state[parser->nstate-1]; + if (state->key) + return 0; + if (VIR_STRNDUP(state->key, (const char *)stringVal, stringLen) < 0) + return 0; + return 1; +} + + +static int +virJSONParserHandleStartMap(void *ctx) +{ + virJSONParserPtr parser = ctx; + virJSONValuePtr value = virJSONValueNewObject(); + + VIR_DEBUG("parser=%p", parser); + + if (!value) + return 0; + + if (virJSONParserInsertValue(parser, value) < 0) { + virJSONValueFree(value); + return 0; + } + + if (VIR_REALLOC_N(parser->state, + parser->nstate + 1) < 0) { + return 0; + } + + parser->state[parser->nstate].value = value; + parser->state[parser->nstate].key = NULL; + parser->nstate++; + + return 1; +} + + +static int +virJSONParserHandleEndMap(void *ctx) +{ + virJSONParserPtr parser = ctx; + virJSONParserStatePtr state; + + VIR_DEBUG("parser=%p", parser); + + if (!parser->nstate) + return 0; + + state = &(parser->state[parser->nstate-1]); + if (state->key) { + VIR_FREE(state->key); + return 0; + } + + VIR_DELETE_ELEMENT(parser->state, parser->nstate - 1, parser->nstate); + + return 1; +} + + +static int +virJSONParserHandleStartArray(void *ctx) +{ + virJSONParserPtr parser = ctx; + virJSONValuePtr value = virJSONValueNewArray(); + + VIR_DEBUG("parser=%p", parser); + + if (!value) + return 0; + + if (virJSONParserInsertValue(parser, value) < 0) { + virJSONValueFree(value); + return 0; + } + + if (VIR_REALLOC_N(parser->state, + parser->nstate + 1) < 0) + return 0; + + parser->state[parser->nstate].value = value; + parser->state[parser->nstate].key = NULL; + parser->nstate++; + + return 1; +} + + +static int +virJSONParserHandleEndArray(void *ctx) +{ + virJSONParserPtr parser = ctx; + virJSONParserStatePtr state; + + VIR_DEBUG("parser=%p", parser); + + if (!(parser->nstate - parser->wrap)) + return 0; + + state = &(parser->state[parser->nstate-1]); + if (state->key) { + VIR_FREE(state->key); + return 0; + } + + VIR_DELETE_ELEMENT(parser->state, parser->nstate - 1, parser->nstate); + + return 1; +} + + +static const yajl_callbacks parserCallbacks = { + virJSONParserHandleNull, + virJSONParserHandleBoolean, + NULL, + NULL, + virJSONParserHandleNumber, + virJSONParserHandleString, + virJSONParserHandleStartMap, + virJSONParserHandleMapKey, + virJSONParserHandleEndMap, + virJSONParserHandleStartArray, + virJSONParserHandleEndArray +}; + + +/* XXX add an incremental streaming parser - yajl trivially supports it */ +virJSONValuePtr +virJSONValueFromString(const char *jsonstring) +{ + yajl_handle hand; + virJSONParser parser = { NULL, NULL, 0, 0 }; + virJSONValuePtr ret = NULL; + int rc; + size_t len = strlen(jsonstring); +# ifndef WITH_YAJL2 + yajl_parser_config cfg = { 0, 1 }; /* Match yajl 2 default behavior */ + VIR_AUTOPTR(virJSONValue) tmp = NULL; +# endif + + VIR_DEBUG("string=%s", jsonstring); + +# ifdef WITH_YAJL2 + hand = yajl_alloc(&parserCallbacks, NULL, &parser); +# else + hand = yajl_alloc(&parserCallbacks, &cfg, NULL, &parser); +# endif + if (!hand) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to create JSON parser")); + goto cleanup; + } + + /* Yajl 2 is nice enough to default to rejecting trailing garbage. + * Yajl 1.0.12 has yajl_get_bytes_consumed to make that detection + * simpler. But we're stuck with yajl 1.0.7 on RHEL 6, which + * happily quits parsing at the end of a valid JSON construct, + * with no visibility into how much more input remains. Wrapping + * things in an array forces yajl to confess the truth. */ +# ifdef WITH_YAJL2 + rc = yajl_parse(hand, (const unsigned char *)jsonstring, len); +# else + rc = yajl_parse(hand, (const unsigned char *)"[", 1); + parser.wrap = 1; + if (VIR_YAJL_STATUS_OK(rc)) + rc = yajl_parse(hand, (const unsigned char *)jsonstring, len); + parser.wrap = 0; + if (VIR_YAJL_STATUS_OK(rc)) + rc = yajl_parse(hand, (const unsigned char *)"]", 1); +# endif + if (!VIR_YAJL_STATUS_OK(rc) || + yajl_complete_parse(hand) != yajl_status_ok) { + unsigned char *errstr = yajl_get_error(hand, 1, + (const unsigned char*)jsonstring, + strlen(jsonstring)); + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse json %s: %s"), + jsonstring, (const char*) errstr); + yajl_free_error(hand, errstr); + virJSONValueFree(parser.head); + goto cleanup; + } + + if (parser.nstate != 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse json %s: unterminated string/map/array"), + jsonstring); + virJSONValueFree(parser.head); + } else { + ret = parser.head; +# ifndef WITH_YAJL2 + /* Undo the array wrapping above */ + tmp = ret; + ret = NULL; + if (virJSONValueArraySize(tmp) > 1) + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse json %s: too many items present"), + jsonstring); + else + ret = virJSONValueArraySteal(tmp, 0); +# endif + } + + cleanup: + yajl_free(hand); + + if (parser.nstate) { + size_t i; + for (i = 0; i < parser.nstate; i++) + VIR_FREE(parser.state[i].key); + VIR_FREE(parser.state); + } + + VIR_DEBUG("result=%p", ret); + + return ret; +} + + +static int +virJSONValueToStringOne(virJSONValuePtr object, + yajl_gen g) +{ + size_t i; + + VIR_DEBUG("object=%p type=%d gen=%p", object, object->type, g); + + switch (object->type) { + case VIR_JSON_TYPE_OBJECT: + if (yajl_gen_map_open(g) != yajl_gen_status_ok) + return -1; + for (i = 0; i < object->data.object.npairs; i++) { + if (yajl_gen_string(g, + (unsigned char *)object->data.object.pairs[i].key, + strlen(object->data.object.pairs[i].key)) + != yajl_gen_status_ok) + return -1; + if (virJSONValueToStringOne(object->data.object.pairs[i].value, g) < 0) + return -1; + } + if (yajl_gen_map_close(g) != yajl_gen_status_ok) + return -1; + break; + case VIR_JSON_TYPE_ARRAY: + if (yajl_gen_array_open(g) != yajl_gen_status_ok) + return -1; + for (i = 0; i < object->data.array.nvalues; i++) { + if (virJSONValueToStringOne(object->data.array.values[i], g) < 0) + return -1; + } + if (yajl_gen_array_close(g) != yajl_gen_status_ok) + return -1; + break; + + case VIR_JSON_TYPE_STRING: + if (yajl_gen_string(g, (unsigned char *)object->data.string, + strlen(object->data.string)) != yajl_gen_status_ok) + return -1; + break; + + case VIR_JSON_TYPE_NUMBER: + if (yajl_gen_number(g, object->data.number, + strlen(object->data.number)) != yajl_gen_status_ok) + return -1; + break; + + case VIR_JSON_TYPE_BOOLEAN: + if (yajl_gen_bool(g, object->data.boolean) != yajl_gen_status_ok) + return -1; + break; + + case VIR_JSON_TYPE_NULL: + if (yajl_gen_null(g) != yajl_gen_status_ok) + return -1; + break; + + default: + return -1; + } + + return 0; +} + + +char * +virJSONValueToString(virJSONValuePtr object, + bool pretty) +{ + yajl_gen g; + const unsigned char *str; + char *ret = NULL; + yajl_size_t len; +# ifndef WITH_YAJL2 + yajl_gen_config conf = { pretty ? 1 : 0, pretty ? " " : " "}; +# endif + + VIR_DEBUG("object=%p", object); + +# ifdef WITH_YAJL2 + g = yajl_gen_alloc(NULL); + if (g) { + yajl_gen_config(g, yajl_gen_beautify, pretty ? 1 : 0); + yajl_gen_config(g, yajl_gen_indent_string, pretty ? " " : " "); + yajl_gen_config(g, yajl_gen_validate_utf8, 1); + } +# else + g = yajl_gen_alloc(&conf, NULL); +# endif + if (!g) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to create JSON formatter")); + goto cleanup; + } + + if (virJSONValueToStringOne(object, g) < 0) { + virReportOOMError(); + goto cleanup; + } + + if (yajl_gen_get_buf(g, &str, &len) != yajl_gen_status_ok) { + virReportOOMError(); + goto cleanup; + } + + ignore_value(VIR_STRDUP(ret, (const char *)str)); + + cleanup: + yajl_gen_free(g); + + VIR_DEBUG("result=%s", NULLSTR(ret)); + + return ret; +} + + +#elif WITH_JANSSON # include <jansson.h> static virJSONValuePtr ++++++ f204cf51-revert-jansson7.patch ++++++ commit f204cf51035f51b979dec18ee526e418139fa874 Author: Ján Tomko <jto...@redhat.com> Date: Mon Aug 13 13:39:39 2018 +0200 Revert "build: require Jansson if QEMU driver is enabled" This reverts commit 01ce04375c3348fd683475e5aa5231149ef6a78a. Jansson cannot parse QEMU's quirky JSON. Revert back to yajl. https://bugzilla.redhat.com/show_bug.cgi?id=1614569 Signed-off-by: Ján Tomko <jto...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Index: libvirt-4.6.0/m4/virt-driver-qemu.m4 =================================================================== --- libvirt-4.6.0.orig/m4/virt-driver-qemu.m4 +++ libvirt-4.6.0/m4/virt-driver-qemu.m4 @@ -27,9 +27,6 @@ AC_DEFUN([LIBVIRT_DRIVER_ARG_QEMU], [ AC_DEFUN([LIBVIRT_DRIVER_CHECK_QEMU], [ AC_REQUIRE([LIBVIRT_CHECK_JANSSON]) - if test "$with_qemu:$with_jansson" = "yes:no"; then - AC_MSG_ERROR([Jansson >= 2.5 is required to build QEMU driver]) - fi if test "$with_qemu" = "check"; then with_qemu=$with_jansson fi ++++++ libvirt-suse-netcontrol.patch ++++++ --- /var/tmp/diff_new_pack.Krf0pS/_old 2018-08-27 13:46:08.188276305 +0200 +++ /var/tmp/diff_new_pack.Krf0pS/_new 2018-08-27 13:46:08.188276305 +0200 @@ -2,7 +2,7 @@ =================================================================== --- libvirt-4.6.0.orig/configure.ac +++ libvirt-4.6.0/configure.ac -@@ -256,6 +256,7 @@ LIBVIRT_ARG_LIBSSH +@@ -255,6 +255,7 @@ LIBVIRT_ARG_LIBSSH LIBVIRT_ARG_LIBXML LIBVIRT_ARG_MACVTAP LIBVIRT_ARG_NETCF @@ -10,7 +10,7 @@ LIBVIRT_ARG_NLS LIBVIRT_ARG_NSS LIBVIRT_ARG_NUMACTL -@@ -299,6 +300,7 @@ LIBVIRT_CHECK_LIBSSH +@@ -297,6 +298,7 @@ LIBVIRT_CHECK_LIBSSH LIBVIRT_CHECK_LIBXML LIBVIRT_CHECK_MACVTAP LIBVIRT_CHECK_NETCF @@ -18,7 +18,7 @@ LIBVIRT_CHECK_NLS LIBVIRT_CHECK_NUMACTL LIBVIRT_CHECK_NWFILTER -@@ -980,6 +982,7 @@ LIBVIRT_RESULT_LIBXL +@@ -977,6 +979,7 @@ LIBVIRT_RESULT_LIBXL LIBVIRT_RESULT_LIBXML LIBVIRT_RESULT_MACVTAP LIBVIRT_RESULT_NETCF