summaryrefslogtreecommitdiff
path: root/debian/patches/Revert-util-avoid-symbol-clash-between-json-libraries.patch
blob: 9c1a032309888cd3ea434a3fc26d9a146bba2531 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
From: =?utf-8?q?J=C3=A1n_Tomko?= <jtomko@redhat.com>
Date: Mon, 13 Aug 2018 13:39:16 +0200
Subject: Revert "util: avoid symbol clash between json libraries"
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

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 <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
 libvirt.spec.in          |   2 -
 src/Makefile.am          |   8 +-
 src/util/Makefile.inc.am |   3 +-
 src/util/virjson.c       |   9 +-
 src/util/virjsoncompat.c | 274 -----------------------------------------------
 src/util/virjsoncompat.h |  88 ---------------
 6 files changed, 7 insertions(+), 377 deletions(-)
 delete mode 100644 src/util/virjsoncompat.c
 delete mode 100644 src/util/virjsoncompat.h

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 19ae55c..4113579 100644
--- a/libvirt.spec.in
+++ b/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
diff --git a/src/Makefile.am b/src/Makefile.am
index 5cefccf..702e900 100644
--- a/src/Makefile.am
+++ b/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 \
@@ -960,8 +960,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 \
@@ -1000,6 +998,10 @@ libvirt_nss_la_CFLAGS = \
 libvirt_nss_la_LDFLAGS = \
 		$(AM_LDFLAGS) \
 		$(NULL)
+
+libvirt_nss_la_LIBADD = \
+		$(JANSSON_LIBS) \
+		$(NULL)
 endif WITH_NSS
 
 
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index 8ef9ee1..71b2b93 100644
--- a/src/util/Makefile.inc.am
+++ b/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) \
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 5bab662..01a387b 100644
--- a/src/util/virjson.c
+++ b/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 *jsonstring)
     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 object,
     json_t *json;
     char *str = NULL;
 
-    if (virJSONInitialize() < 0)
-        return NULL;
-
     if (pretty)
         flags |= JSON_INDENT(2);
     else
diff --git a/src/util/virjsoncompat.c b/src/util/virjsoncompat.c
deleted file mode 100644
index 6c853e9..0000000
--- a/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 */
diff --git a/src/util/virjsoncompat.h b/src/util/virjsoncompat.h
deleted file mode 100644
index d9b7765..0000000
--- a/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_ */