1 diff -r f72b99fccfca -r 716d6d48e647 Config.mk
2 --- a/Config.mk Tue Dec 20 08:31:40 2011 +0100
3 +++ b/Config.mk Tue Dec 20 13:52:55 2011 +0100
4 @@ -186,6 +186,11 @@ CONFIG_LIBICONV := $(shell export OS="
5 . $(XEN_ROOT)/tools/check/funcs.sh; \
6 has_lib libiconv.so && echo 'y' || echo 'n')
8 +CONFIG_YAJL_VERSION := $(shell export OS="`uname -s`"; \
9 + export CHECK_INCLUDES="$(CHECK_INCLUDES)"; \
10 + . $(XEN_ROOT)/tools/check/funcs.sh; \
11 + has_header yajl/yajl_version.h && echo 'y' || echo 'n')
13 # Enable XSM security module (by default, Flask).
15 FLASK_ENABLE ?= $(XSM_ENABLE)
16 diff -r f72b99fccfca -r 716d6d48e647 tools/check/check_yajl_lib
17 --- a/tools/check/check_yajl_lib Tue Dec 20 08:31:40 2011 +0100
18 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21 -# CHECK-BUILD CHECK-INSTALL
25 -has_lib libyajl.so.1 || fail "can't find libyajl.so.1 version 1"
26 diff -r f72b99fccfca -r 716d6d48e647 tools/libxl/Makefile
27 --- a/tools/libxl/Makefile Tue Dec 20 08:31:40 2011 +0100
28 +++ b/tools/libxl/Makefile Tue Dec 20 13:52:55 2011 +0100
29 @@ -19,6 +19,10 @@ ifeq ($(CONFIG_Linux),y)
30 LIBUUID_LIBS += -luuid
33 +ifeq ($(CONFIG_YAJL_VERSION),y)
34 +CFLAGS += -DHAVE_YAJL_VERSION
38 LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore)
39 $(LDLIBS_libblktapctl) $(UTIL_LIBS) $(LIBUUID_LIBS)
41 diff -r f72b99fccfca -r 716d6d48e647 tools/libxl/libxl_json.c
42 --- a/tools/libxl/libxl_json.c Tue Dec 20 08:31:40 2011 +0100
43 +++ b/tools/libxl/libxl_json.c Tue Dec 20 13:52:55 2011 +0100
44 @@ -519,7 +519,11 @@ static bool is_decimal(const char *s, un
49 +static int json_callback_number(void *opaque, const char *s, size_t len)
51 static int json_callback_number(void *opaque, const char *s, unsigned int len)
54 libxl__yajl_ctx *ctx = opaque;
55 libxl__json_object *obj = NULL;
56 @@ -575,8 +579,13 @@ out:
61 +static int json_callback_string(void *opaque, const unsigned char *str,
64 static int json_callback_string(void *opaque, const unsigned char *str,
68 libxl__yajl_ctx *ctx = opaque;
70 @@ -608,8 +617,13 @@ static int json_callback_string(void *op
75 +static int json_callback_map_key(void *opaque, const unsigned char *str,
78 static int json_callback_map_key(void *opaque, const unsigned char *str,
82 libxl__yajl_ctx *ctx = opaque;
84 @@ -772,17 +786,26 @@ libxl__json_object *libxl__json_parse(li
85 DEBUG_GEN_ALLOC(&yajl_ctx);
87 if (yajl_ctx.hand == NULL) {
89 + yajl_ctx.hand = yajl_alloc(&callbacks, NULL, &yajl_ctx);
91 yajl_parser_config cfg = {
95 yajl_ctx.hand = yajl_alloc(&callbacks, &cfg, NULL, &yajl_ctx);
98 status = yajl_parse(yajl_ctx.hand, (const unsigned char *)s, strlen(s));
99 if (status != yajl_status_ok)
103 + status = yajl_complete_parse(yajl_ctx.hand);
105 + status = yajl_parse_complete(yajl_ctx.hand);
108 - status = yajl_parse_complete(yajl_ctx.hand);
109 if (status != yajl_status_ok)
112 @@ -834,14 +857,25 @@ static const char *yajl_gen_status_to_st
113 char *libxl__object_to_json(libxl_ctx *ctx, const char *type,
114 libxl__gen_json_callback gen, void *p)
116 +#ifndef HAVE_YAJL_V2
117 yajl_gen_config conf = { 1, " " };
119 const unsigned char *buf;
124 unsigned int len = 0;
130 + hand = yajl_gen_alloc(NULL);
132 hand = yajl_gen_alloc(&conf, NULL);
138 diff -r f72b99fccfca -r 716d6d48e647 tools/libxl/libxl_json.h
139 --- a/tools/libxl/libxl_json.h Tue Dec 20 08:31:40 2011 +0100
140 +++ b/tools/libxl/libxl_json.h Tue Dec 20 13:52:55 2011 +0100
143 #include <yajl/yajl_gen.h>
145 +#ifdef HAVE_YAJL_VERSION
146 +# include <yajl/yajl_version.h>
149 #include <_libxl_types_json.h>
150 #include <_libxl_types_internal_json.h>
152 +/* YAJL version check */
153 +#if defined(YAJL_MAJOR) && (YAJL_MAJOR > 1)
154 +# define HAVE_YAJL_V2 1
157 #endif /* LIBXL_JSON_H */
158 diff -r f72b99fccfca -r 716d6d48e647 tools/libxl/libxl_qmp.c
159 --- a/tools/libxl/libxl_qmp.c Tue Dec 20 08:31:40 2011 +0100
160 +++ b/tools/libxl/libxl_qmp.c Tue Dec 20 13:52:55 2011 +0100
161 @@ -453,15 +453,26 @@ static char *qmp_send_prepare(libxl__gc
162 qmp_callback_t callback, void *opaque,
163 qmp_request_context *context)
165 +#ifndef HAVE_YAJL_V2
166 yajl_gen_config conf = { 0, NULL };
168 const unsigned char *buf = NULL;
173 unsigned int len = 0;
177 callback_id_pair *elm = NULL;
180 + hand = yajl_gen_alloc(NULL);
182 hand = yajl_gen_alloc(&conf, NULL);