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@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
This commit is contained in:
Anthony PERARD authored and Wei Liu committed 2018-08-21 12:16:02 +01:00
1 parent 544c15c827
commit 7fbaf06d2d
2 files changed
+35

No files matched your search

+3
View File
@@ -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);
+32
View File
@@ -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;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.