libxl: add support for yajl 2.x
PATCH v3 1/1 libxl: add support for yajl 2.x
# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1326606960 -3600
# Node ID a1986ef30b7dab4f60fe5cda70856f5751a9fde2 # Parent cd47dde439e688cac244c7eb9f55d826c85c844f
libxl: add support for yajl 2.x
This patch adds support for yajl versions 2.x, while retaining 1.x compatibility. All the needed ifdefs can be found in libxl_json.h.
Tested with yajl 2.0.3 and 1.0.12.
Changes since v2:
* Moved all ifdefs to libxl_json.h, as Ian Jackson suggested.
Changes since v1:
* Check if yajl_version.h is present before trying to include it.
Config.mk +5 -0
@@ -181,6 +181,11 @@ CHECK_INCLUDES = $(EXTRA_INCLUDES) $(PRE EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all EMBEDDED_EXTRA_CFLAGS += -fno-exceptions +CONFIG_YAJL_VERSION := $(shell export OS="`uname -s`"; \ + export CHECK_INCLUDES="$(CHECK_INCLUDES)"; \ + . $(XEN_ROOT)/tools/check/funcs.sh; \ + has_header yajl/yajl_version.h && echo 'y' || echo 'n') + # Enable XSM security module (by default, Flask). XSM_ENABLE ?= n FLASK_ENABLE ?= $(XSM_ENABLE)
tools/check/check_yajl_lib deleted +0 -6
@@ -1,6 +0,0 @@ -#!/bin/sh -# CHECK-BUILD CHECK-INSTALL - -. ./funcs.sh - -has_lib libyajl.so.1 || fail "can't find libyajl.so.1 version 1"
tools/libxl/Makefile +4 -0
@@ -19,6 +19,10 @@ ifeq ($(CONFIG_Linux),y) LIBUUID_LIBS += -luuid endif +ifeq ($(CONFIG_YAJL_VERSION),y) +CFLAGS += -DHAVE_YAJL_VERSION +endif + LIBXL_LIBS = LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(UTIL_LIBS) $(LIBUUID_LIBS)
tools/libxl/libxl_json.c +7 -12
@@ -519,7 +519,7 @@ static bool is_decimal(const char *s, unreturn false; } -static int json_callback_number (void *opaque,const char *s,unsigned int len) +static int json_callback_number (void *opaque,const char *s,libxl_yajl_length len) {libxl__yajl_ctx *ctx = opaque;libxl__json_object *obj =NULL ;
@@ -576,7 +576,7 @@ out: }static int json_callback_string (void *opaque,const unsigned char *str, -unsigned int len) +libxl_yajl_length len) {libxl__yajl_ctx *ctx = opaque;char *t =NULL ;
@@ -609,7 +609,7 @@ static int json_callback_string(void *op }static int json_callback_map_key (void *opaque,const unsigned char *str, -unsigned int len) +libxl_yajl_length len) {libxl__yajl_ctx *ctx = opaque;char *t =NULL ;
@@ -772,17 +772,13 @@ libxl__json_object *libxl__json_parse(liDEBUG_GEN_ALLOC (&yajl_ctx);if (yajl_ctx.hand ==NULL ) { -yajl_parser_config cfg = { - .allowComments =1 , - .checkUTF8 =1 , - }; - yajl_ctx.hand =yajl_alloc (&callbacks, &cfg,NULL , &yajl_ctx); + yajl_ctx.hand =libxl__yajl_alloc (&callbacks,NULL , &yajl_ctx); } status =yajl_parse (yajl_ctx.hand, (const unsigned char *)s,strlen (s));if (status != yajl_status_ok) goto out; - status =yajl_parse_complete (yajl_ctx.hand); + status =yajl_complete_parse (yajl_ctx.hand);if (status != yajl_status_ok) goto out;
@@ -834,14 +830,13 @@ static const char *yajl_gen_status_to_stchar *libxl__object_to_json (libxl_ctx *ctx,const char *type,libxl__gen_json_callback gen,void *p) { -yajl_gen_config conf = {1 ," " };const unsigned char *buf;char *ret =NULL ; -unsigned int len =0 ; +libxl_yajl_length len =0 ;yajl_gen_status s;yajl_gen hand; - hand =yajl_gen_alloc (&conf,NULL ); + hand =libxl__yajl_gen_alloc (NULL );if (!hand)return NULL ;
tools/libxl/libxl_json.h +47 -0
55 lines not on this page · raw message
tools/libxl/libxl_qmp.c +3 -3
@@ -453,15 +453,15 @@ static char *qmp_send_prepare(libxl__gc qmp_callback_t callback, void *opaque, qmp_request_context *context) { - yajl_gen_config conf = { 0, NULL }; const unsigned char *buf = NULL;char *ret =NULL ; -unsigned int len =0 ; +libxl_yajl_length len =0 ;yajl_gen_status s;yajl_gen hand;callback_id_pair *elm =NULL ; - hand =yajl_gen_alloc (&conf,NULL ); + hand =libxl__yajl_gen_alloc (NULL ); +if (!hand) {return NULL ; }
Roger Pau Monne writes ("[Xen-devel] [PATCH v3] libxl: add support for yajl 2.x"):
Quoted 4 lines
libxl: add support for yajl 2.x
This patch adds support for yajl versions 2.x, while retaining 1.x compatibility. All the needed ifdefs can be found in
libxl_json.h.
Thanks. I'm afraid this needs a refresh:
patching file tools/libxl/libxl_json.h
Hunk #1 FAILED at 16.
1 out of 1 hunk FAILED -- saving rejects to file tools/libxl/libxl_json.h.rej
Also, while you're at it:
tools/libxl/libxl_json.h line 47
Quoted 5 lines
tools/libxl/libxl_json.h +5
-0+static inline yajl_gen libxl__yajl_gen_alloc (const yajl_alloc_funcs *allocFuncs) +{ +return yajl_gen_alloc (allocFuncs); +} +#else
A couple of blank lines around this #ifs and #elses might be nice. And also I would say
#else /* !HAVE_YAJL_V2 */
and
#endif /* !HAVE_YAJL_V2 */
(But I would have committed it without those changes if it had applied cleanly.)
Thanks,
Ian.
2012/1/27 Ian Jackson <[email protected]>:
Quoted 25 lines
Roger Pau Monne writes ("[Xen-devel] [PATCH v3] libxl: add support for yajl 2.x"):
Quoted 4 lines
libxl: add support for yajl 2.x
This patch adds support for yajl versions 2.x, while retaining 1.x compatibility. All the needed ifdefs can be found in
libxl_json.h.Thanks. I'm afraid this needs a refresh:
patching file
tools/libxl/libxl_json.h
Hunk #1 FAILED at 16.
1 out of 1 hunk FAILED -- saving rejects to filetools/libxl/libxl_json.h.rejAlso, while you're at it:
tools/libxl/libxl_json.h line 47
Quoted 5 lines
tools/libxl/libxl_json.h +5
-0+static inline yajl_gen libxl__yajl_gen_alloc (const yajl_alloc_funcs *allocFuncs) +{ + return yajl_gen_alloc(allocFuncs); +} +#else A couple of blank lines around this #ifs and #elses might be nice. And also I would say
#else /* !HAVE_YAJL_V2 */
and
#endif /* !HAVE_YAJL_V2 */
Quoted 2 lines
(But I would have committed it without those changes if it had applied cleanly.)
I've sent and updated version, sorry for the delay, my local mercurial repro was totally borked, don't know why...
Quoted 2 lines
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel