libxl: Convert libxl__object_to_json() to json-c

- libxl changes:

While doing so, we rename all "*_gen_json" function to "*_gen_jso" as
they have different prototype. All the function pointer are been cast
to (libxl__gen_json_callback) by "gentypes.py" when generating
"*_to_json()" functions.

We also introduce a few more "*_gen_jso" functions for "int" and
"bool" because we can't use json_object_*() functions from json-c
directly like it's done with yajl.

To make the generation of _libxl_types*json.[ch] with both YAJL and
json-c we add "--libjsonc" to gentypes.py so it can generate
functions/types for both.

Also introducing "jsonc_json_gen_fn" in the IDL, to be able to point
to a different function when using json-c.

Also, don't export any of the new *_gen_jso() function, at the cost of
having "_hidden" macro in semi-public headers.

- xl changes:

Also, rework the implementation of printf_info() in `xl` to avoid
using libxl_domain_config_gen_json() which isn't available without
YAJL. The implementation using "json_object" call
libxl_domain_config_to_json() which generate a plain string of JSON,
which we parse to add it to our own json; this avoid a dependency on
the json library used by libxl.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
This commit is contained in:
Anthony PERARD authored and Andrew Cooper committed 2025-10-06 12:36:50 +01:00
1 parent a6fd4a1c55
commit f6c6f2679d
10 files changed
+729 -20

No files matched your search

+17
View File
@@ -28,6 +28,22 @@
#endif
#endif
#ifdef HAVE_LIBJSONC
#ifndef _hidden
#define _hidden
#endif
_hidden int libxl__uint64_gen_jso(json_object **jso_r, uint64_t val);
_hidden int libxl_defbool_gen_jso(json_object **jso_r, libxl_defbool *p);
_hidden int libxl_uuid_gen_jso(json_object **jso_r, libxl_uuid *p);
_hidden int libxl_mac_gen_jso(json_object **jso_r, libxl_mac *p);
_hidden int libxl_bitmap_gen_jso(json_object **jso_r, libxl_bitmap *p);
_hidden int libxl_cpuid_policy_list_gen_jso(json_object **jso_r,libxl_cpuid_policy_list *p);
_hidden int libxl_string_list_gen_jso(json_object **jso_r,libxl_string_list *p);
_hidden int libxl_key_value_list_gen_jso(json_object **jso_r, libxl_key_value_list *p);
_hidden int libxl_hwcap_gen_jso(json_object **jso_r, libxl_hwcap *p);
_hidden int libxl_ms_vm_genid_gen_jso(json_object **jso_r, libxl_ms_vm_genid *p);
#endif
#if defined(HAVE_LIBYAJL)
yajl_gen_status libxl__uint64_gen_json(yajl_gen hand, uint64_t val);
yajl_gen_status libxl_defbool_gen_json(yajl_gen hand, libxl_defbool *p);
yajl_gen_status libxl_uuid_gen_json(yajl_gen hand, libxl_uuid *p);
@@ -40,6 +56,7 @@ yajl_gen_status libxl_key_value_list_gen_json(yajl_gen hand,
libxl_key_value_list *p);
yajl_gen_status libxl_hwcap_gen_json(yajl_gen hand, libxl_hwcap *p);
yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen hand, libxl_ms_vm_genid *p);
#endif
#include <_libxl_types_json.h>
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.