[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl_json: libxl__json_object_to_json
commit 7fbaf06d2de7f1c44bb41396acdbfb94f74e1cf9 Author: Anthony PERARD <anthony.perard@xxxxxxxxxx> AuthorDate: Fri May 25 15:07:14 2018 +0100 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Tue Aug 21 12:16:02 2018 +0100 libxl_json: libxl__json_object_to_json Allow to generate a JSON string from a libxl__json_object, useful for debugging. Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_json.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 1bc9394135..802382c704 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2037,6 +2037,9 @@ _hidden void libxl__json_object_free(libxl__gc *gc_opt, _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s); +_hidden char *libxl__json_object_to_json(libxl__gc *gc, + const libxl__json_object *args); + /* Based on /local/domain/$domid/dm-version xenstore key * default is qemu xen traditional */ _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid); diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c index b7f9077f0d..cd78313df2 100644 --- a/tools/libxl/libxl_json.c +++ b/tools/libxl/libxl_json.c @@ -1017,6 +1017,38 @@ out: return ret; } +char *libxl__json_object_to_json(libxl__gc *gc, + const libxl__json_object *args) +{ + const unsigned char *buf; + libxl_yajl_length len; + yajl_gen_status s; + yajl_gen hand; + char *ret = NULL; + int rc; + + if (!args) + return NULL; + + hand = libxl_yajl_gen_alloc(NULL); + if (!hand) + return NULL; + + rc = libxl__json_object_to_yajl_gen(gc, hand, args); + if (rc) + goto out; + + s = yajl_gen_get_buf(hand, &buf, &len); + if (s) + goto out; + + ret = libxl__strndup(gc, (const char *)buf, len); + +out: + yajl_gen_free(hand); + return ret; +} + yajl_gen_status libxl__uint64_gen_json(yajl_gen hand, uint64_t val) { char *num; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |