From: Anthony PERARD <anthony@xenproject.org>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Jason Andryuk <jason.andryuk@amd.com>,
xen-devel@lists.xenproject.org,
Anthony PERARD <anthony.perard@vates.tech>,
Juergen Gross <jgross@suse.com>
Subject: Re: [XEN PATCH 07/11] libxl: libxl__object_to_json() to json-c
Date: Fri, 29 Aug 2025 17:32:54 +0200 [thread overview]
Message-ID: <aLHIJtn2Eyhx537E@l14> (raw)
In-Reply-To: <eae86371-51f6-4df3-8ca3-723303864126@citrix.com>
On Wed, Aug 27, 2025 at 06:59:14PM +0100, Andrew Cooper wrote:
> On 27/08/2025 6:51 pm, Jason Andryuk wrote:
> > On 2025-08-08 10:55, Anthony PERARD wrote:
> >> From: Anthony PERARD <anthony.perard@vates.tech>
> >>
> >> - 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>
> >
> >> @@ -358,6 +535,36 @@ int libxl__mac_parse_json(libxl__gc *gc, const
> >> libxl__json_object *o,
> >> return libxl__parse_mac(libxl__json_object_get_string(o), *p);
> >> }
> >> +#ifdef HAVE_LIBJSONC
> >> +int libxl_hwcap_gen_jso(json_object **jso_r, libxl_hwcap *p)
> >> +{
> >> + json_object *jso;
> >> + int i;
> >> + int rc = ERROR_FAIL;
> >> +
> >> + jso = json_object_new_array();
> >> + if (!jso) goto out;
> >> +
> >> + for(i=0; i<4; i++) {
> >
> > typedef uint32_t libxl_hwcap[8];
> >
> > I see this is the same as the yajl implementation, but should this be 8?
Yeah, looks like it should be ARRAY_SIZE(p). But that would want fixing
in a different patch. And since no one complained about missing bits in
this json conversion, I guess it's not used.
We would need to also fix libxl__hwcap_parse_json(), to parse up to 8
items, and be able to deal with missing 4 of them.
> >
> > The remainder looks good:
> >
> > Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
>
> A tangent, but physinfo.hw_cap (which libxl_hwcap wraps) is as good as
> stack rubble. It's not exactly random data, but it is a view of an
> internal Xen structure which has been reformatted multiple times before
> we even realised it was exported, then continued being reformatting it
> because it's a gross laying violation that noone could possibly be using
> anyway.
It's display in `xl info`, surely it's useful for someone :-), a long
long time ago since it seems to be inherited from `xm info`.
> It needs purging from libxl and the sysctl interface, and if that makes
> JSON easier, then lets get it done.
It would be more work, not less. Removing things from libxl's api is
annoying. But I guess we can look at removing that later.
Cheers,
--
Anthony PERARD
next prev parent reply other threads:[~2025-08-29 15:33 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 14:55 [XEN PATCH 00/11] Allow to build libxl and other tools with json-c instead of yajl Anthony PERARD
2025-08-08 14:55 ` [XEN PATCH 01/11] xl: move printf_info prototype to an header Anthony PERARD
2025-08-27 14:55 ` Jason Andryuk
2025-08-08 14:55 ` [XEN PATCH 02/11] libxl: Remove duplicate libxl_domain_config_gen_json prototype Anthony PERARD
2025-08-27 14:55 ` Jason Andryuk
2025-08-08 14:55 ` [XEN PATCH 03/11] libxl: remove duplicated libxl__yajl_gen_asciiz() prototype Anthony PERARD
2025-08-27 14:56 ` Jason Andryuk
2025-08-08 14:55 ` [XEN PATCH 04/11] tools/configure: Introduce deps on json-c lib for libxl Anthony PERARD
2025-08-11 10:48 ` Andrew Cooper
2025-08-13 15:42 ` Anthony PERARD
2025-08-27 15:01 ` Jason Andryuk
2025-08-29 13:17 ` Anthony PERARD
2025-08-31 14:42 ` Jason Andryuk
2025-08-08 14:55 ` [XEN PATCH 05/11] libxl: Convert libxl__json_parse() to use json-c Anthony PERARD
2025-08-27 15:20 ` Jason Andryuk
2025-08-08 14:55 ` [XEN PATCH 06/11] libxl: convert libxl__json_object_to_yajl_gen to libxl__json_object_to_libjsonc_object Anthony PERARD
2025-08-27 15:37 ` Jason Andryuk
2025-08-29 13:56 ` Anthony PERARD
2025-08-31 14:51 ` Jason Andryuk
2025-09-29 9:52 ` Anthony PERARD
2025-08-08 14:55 ` [XEN PATCH 07/11] libxl: libxl__object_to_json() to json-c Anthony PERARD
2025-08-27 17:51 ` Jason Andryuk
2025-08-27 17:59 ` Andrew Cooper
2025-08-29 15:32 ` Anthony PERARD [this message]
2025-08-08 14:55 ` [XEN PATCH 08/11] libxl: convert libxl__json_object_to_json() to json_object Anthony PERARD
2025-08-27 17:54 ` Jason Andryuk
2025-08-08 14:56 ` [XEN PATCH 09/11] tools/libxenstat: Use json-c when available Anthony PERARD
2025-08-27 18:00 ` Jason Andryuk
2025-08-08 14:56 ` [XEN PATCH 10/11] configure: Use json-c by default, fallback to yajl Anthony PERARD
2025-08-08 14:56 ` [XEN PATCH 11/11] Update CHANGELOG and README with dependency on json-c Anthony PERARD
2025-08-11 8:27 ` Oleksii Kurochko
2025-08-11 10:55 ` Andrew Cooper
2025-08-11 14:37 ` Anthony PERARD
2025-08-08 15:14 ` [XEN PATCH 00/11] Allow to build libxl and other tools with json-c instead of yajl Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aLHIJtn2Eyhx537E@l14 \
--to=anthony@xenproject.org \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=jason.andryuk@amd.com \
--cc=jgross@suse.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.