From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664999; cv=none; d=zohomail.com; s=zohoarc; b=ODoc8PfSmiSu7AAnlGo19JFCC9ucbO778orkdbTiH8Q/mWhAwW7SAi0lWVsQ0G8BkWxk8cw69J9Q4foNLVU0WIfz/HPb1GHy5p0ONBTdo0LvJx+wYaM48fNqwKoJsBt0vgc+aUY8onsDIgtvjwiJvdUxa4i03hWTlWRa5vidC5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664999; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=raD2DxVICJDfaNLubZN80EJ1w54pDYHTSpJpYmDjXXs=; b=cvUQnxOr97nKmXmff6Klw0svXY7WEvEpVzzNgBW7XZQb3dY578vxoKiTMZ8yTTrlm/v2L6kXIs2F4luuNQfxf0y2/qGmRIttsNZ+gacpgTQ4p2Aet4NojJf6d4n2I7EUoDmN+ZWlQ/SQ4AVnJPe8yimqawkFkLzWAyDcegn6btY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175466499908281.58232862106183; Fri, 8 Aug 2025 07:56:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074662.1437142 (Exim 4.92) (envelope-from ) id 1ukOVs-0008JE-GV; Fri, 08 Aug 2025 14:56:08 +0000 Received: by outflank-mailman (output) from mailman id 1074662.1437142; Fri, 08 Aug 2025 14:56:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVs-0008J7-Dh; Fri, 08 Aug 2025 14:56:08 +0000 Received: by outflank-mailman (input) for mailman id 1074662; Fri, 08 Aug 2025 14:56:06 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVq-0008IZ-TY for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:06 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVq-007zr5-1s; Fri, 08 Aug 2025 14:56:06 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVq-009BYT-0y; Fri, 08 Aug 2025 14:56:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=raD2DxVICJDfaNLubZN80EJ1w54pDYHTSpJpYmDjXXs=; b=Vul31LkpIc2hYvJ13DGCLv6uKG Ztrg7XC5+LRyqnCPjLrwyrxlQhGLmLNImC4S0fwhtzWuxKdS7Dh0/CgSM1Mn5GaU/QnP9Ja5zIGNw JcyrNYKrTEukecn8VRSqC515AgwQ5R5IHRz9hLDNlQpWv2WFTc0oGhkqlSL/SUxL4O1Q=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD Subject: [XEN PATCH 01/11] xl: move printf_info prototype to an header Date: Fri, 8 Aug 2025 16:55:52 +0200 Message-Id: <20250808145602.41716-2-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754665001411124100 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD In a single place. Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/xl/xl.h | 3 +++ tools/xl/xl_info.c | 3 --- tools/xl/xl_misc.c | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 45745f0dbb..9000df00de 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -310,6 +310,9 @@ extern void printf_info_sexp(int domid, libxl_domain_co= nfig *d_config, FILE *fh) extern void apply_global_affinity_masks(libxl_domain_type type, libxl_bitmap *vcpu_affinity_array, unsigned int size); +void printf_info(enum output_format output_format, + int domid, + libxl_domain_config *d_config, FILE *fh); =20 #define XL_GLOBAL_CONFIG XEN_CONFIG_DIR "/xl.conf" #define XL_LOCK_FILE XEN_LOCK_DIR "/xl" diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index eb019e3ee9..3fbc0698b7 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -96,9 +96,6 @@ static yajl_gen_status printf_info_one_json(yajl_gen hand= , int domid, return s; } =20 -void printf_info(enum output_format output_format, - int domid, - libxl_domain_config *d_config, FILE *fh); void printf_info(enum output_format output_format, int domid, libxl_domain_config *d_config, FILE *fh) diff --git a/tools/xl/xl_misc.c b/tools/xl/xl_misc.c index 08f0fb6dc9..f0167e1603 100644 --- a/tools/xl/xl_misc.c +++ b/tools/xl/xl_misc.c @@ -256,9 +256,6 @@ int main_dump_core(int argc, char **argv) return EXIT_SUCCESS; } =20 -extern void printf_info(enum output_format output_format, - int domid, - libxl_domain_config *d_config, FILE *fh); int main_config_update(int argc, char **argv) { uint32_t domid; --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664992; cv=none; d=zohomail.com; s=zohoarc; b=Tab7OkgDEAZEdmAdD1DvJ+8qXtgOPGaMUtqBx1AdPWQRq3YSX5AFObGkOo7AtYt7PH/uSLBOyHBq/Yi56f5g2DzAXrltyX+46rA0ob2H3hSxksfN5Tkucl/RyJ41HfrT6lOh/5BmLsSPWA8DfjqzqbxAmZ9xR7iBv4WJF4HJi0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664992; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=k+bhmnBEE95exmmfH0gnf9+dEFpUHSD0leW6AxF9H9o=; b=kfXuFTZj8F4hnR+IeYmcGN3TNsKjs+AnF2Y/QWmEhpH4N97fTGQ4LVh7WQqpEzyRQ4dsVJFzxIAznEfoaqRcWjzkdVXVIodMJqZJGgssePjK9LY5wVl1+9zt8boDriC/0jBE67+aFB0sFhuEvuvfLqx11bsYeDPkvT80CICrRTA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754664992670127.91483040969467; Fri, 8 Aug 2025 07:56:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074664.1437153 (Exim 4.92) (envelope-from ) id 1ukOVt-0008Qj-0z; Fri, 08 Aug 2025 14:56:09 +0000 Received: by outflank-mailman (output) from mailman id 1074664.1437153; Fri, 08 Aug 2025 14:56:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVs-0008PH-Sq; Fri, 08 Aug 2025 14:56:08 +0000 Received: by outflank-mailman (input) for mailman id 1074664; Fri, 08 Aug 2025 14:56:07 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVr-0008J1-Ka for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:07 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVr-007zrE-1I; Fri, 08 Aug 2025 14:56:07 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVr-009BYT-0R; Fri, 08 Aug 2025 14:56:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=k+bhmnBEE95exmmfH0gnf9+dEFpUHSD0leW6AxF9H9o=; b=K/G9SAdrcZ6aFpedRTh0sPWLD3 dn5YzTV26u8XzxR23nEvgofIeasByb9DlHcGRYPBKm72LHTQqyw3b2zJGDa1ESbDn54UdK+ABJK4q T5EqYyUD0LNXtxpW0Xwc/lsIjJi0AEI4vkDqEBg2z86HtPl8yQl6wXtKfJ0j85P0JAao=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Juergen Gross Subject: [XEN PATCH 02/11] libxl: Remove duplicate libxl_domain_config_gen_json prototype Date: Fri, 8 Aug 2025 16:55:53 +0200 Message-Id: <20250808145602.41716-3-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754664995282124100 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD Since f9e681d3d1b8, the prototype of libxl_domain_config_gen_json is generated from IDL in _libxl_types_json.h. Fixes: f9e681d3d1b8 ("libxl: move definition of libxl_domain_config into th= e IDL") Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/include/libxl_json.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/include/libxl_json.h b/tools/include/libxl_json.h index 260783bfde..3f97267eae 100644 --- a/tools/include/libxl_json.h +++ b/tools/include/libxl_json.h @@ -90,7 +90,4 @@ static inline yajl_gen libxl_yajl_gen_alloc(const yajl_al= loc_funcs *allocFuncs) =20 #endif /* !HAVE_YAJL_V2 */ =20 -yajl_gen_status libxl_domain_config_gen_json(yajl_gen hand, - libxl_domain_config *p); - #endif /* LIBXL_JSON_H */ --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664992; cv=none; d=zohomail.com; s=zohoarc; b=OcAJcNA13/jMw4i3sBlMebBDza/D8KUV9nsq55fQ8ehIaBC8gzLFECEtPxTExJHkmrlqygYKLZRJP4n9U/VMIYgYtErvkiaGs8XI2kiWZNj2g+vDnFT5c8wAL7KrGrfqlm6CzBNAbnnC4+aTsbng8uUL1yej77FxiS0DfJxtM1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664992; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CCPKtC0shQwlH1BCzBftuuKxzSUgHWgFXX9AJ0JhOKY=; b=GqmcUYt/lby01Gba2JIzxkPwRsEmXGN8lAtawjqw6TWFLx94yRGIS27WzkzGD5myiJYczil//Ie6GjVqkvF6UbvRXeDTf+zBpi6/fIIBnHi3KInlWZr3d6fy1TWt6H9bN0vzDdMdclSDMkUFzaD4Z2Gih7qsW0b7sQzHfFxH8ho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17546649924401005.5031942187557; Fri, 8 Aug 2025 07:56:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074665.1437173 (Exim 4.92) (envelope-from ) id 1ukOVu-0000X6-8c; Fri, 08 Aug 2025 14:56:10 +0000 Received: by outflank-mailman (output) from mailman id 1074665.1437173; Fri, 08 Aug 2025 14:56:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVu-0000Wz-4u; Fri, 08 Aug 2025 14:56:10 +0000 Received: by outflank-mailman (input) for mailman id 1074665; Fri, 08 Aug 2025 14:56:08 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVs-0008JK-GM for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:08 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVs-007zrL-0o; Fri, 08 Aug 2025 14:56:08 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVr-009BYT-38; Fri, 08 Aug 2025 14:56:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=CCPKtC0shQwlH1BCzBftuuKxzSUgHWgFXX9AJ0JhOKY=; b=i8CX6XAz3rZHc+IEL4zubcuVDm KlQMZusduGAEouJznIY0K//WwqePAsfA39EaQm+L6DXMf7jgI/bzqwu6IZmwGNqmVQkv3kNNnAgMN CfKdAPI69q+A833Lx2OOWwCJsmiLg7AAjPgp9ISCa6lokj8kTx7u9HiEo5WTgq1jpvuI=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Juergen Gross Subject: [XEN PATCH 03/11] libxl: remove duplicated libxl__yajl_gen_asciiz() prototype Date: Fri, 8 Aug 2025 16:55:54 +0200 Message-Id: <20250808145602.41716-4-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754664995286124100 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/light/libxl_internal.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 2a5b233caa..4b6587a27a 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -1993,8 +1993,6 @@ _hidden char *libxl__cpupoolid_to_name(libxl__gc *gc,= uint32_t poolid); _hidden int libxl__enum_from_string(const libxl_enum_string_table *t, const char *s, int *e) NN(2); =20 -_hidden yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, const char *= str); - _hidden yajl_gen_status libxl__string_gen_json(yajl_gen hand, const char *= p); =20 typedef yajl_gen_status (*libxl__gen_json_callback)(yajl_gen hand, void *); --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664993; cv=none; d=zohomail.com; s=zohoarc; b=D46KlSmwoDybWcEYxZ/XKUtR7tBMHrnQbSwGrffjkNju14yFEB8eWMnmW1TEVsIUWTCt0eHt3j4TVOpAsqaTcV0OoMnTyHeaP6k0qE0nJJluy2haaOMNt48+dqq5Zu93bLypY+/yH5XoExA2bhl10gLlHewvP2sXpf9kPRNvMyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664993; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xVf4OX8RTJY7OuVusTIEIHCb9A67uli5402HnQS/1A4=; b=h/FmQxOBxkFvMxJWXQp66P00284aGBvNED2xUjrm9LknQ5R38yLYyEpdjrD8RXv2solSvmLtZzO+95bMAafpjPshsaa3Qo7hEmPDnosemHaTSK4cGaliszwFhT5WcrQOnCthmr7m3I2Y6sWzpjX2DTfJ6wdP9Uxp8EUpTbJngpE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754664993656864.680330764997; Fri, 8 Aug 2025 07:56:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074666.1437179 (Exim 4.92) (envelope-from ) id 1ukOVu-0000Yn-Hv; Fri, 08 Aug 2025 14:56:10 +0000 Received: by outflank-mailman (output) from mailman id 1074666.1437179; Fri, 08 Aug 2025 14:56:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVu-0000YX-CL; Fri, 08 Aug 2025 14:56:10 +0000 Received: by outflank-mailman (input) for mailman id 1074666; Fri, 08 Aug 2025 14:56:09 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVt-00008B-7a for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:09 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVt-007zrT-0F; Fri, 08 Aug 2025 14:56:09 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVs-009BYT-2d; Fri, 08 Aug 2025 14:56:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=xVf4OX8RTJY7OuVusTIEIHCb9A67uli5402HnQS/1A4=; b=PAp8+tUObouyoV7Q3feKgOs4KJ bI6VKXuLkaKAth9yVNlidl0QVptXYVvXp6M9jEd+rCn500hT4ulL17+c6+ePGRWl2MLLguOfReHEI wacDlYTQhUhnAqYQpdfkpSKv/Y8hWO9yNXyvyMyHEMjUF9yaH559udyf/skXqsUAGOYI=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Juergen Gross Subject: [XEN PATCH 04/11] tools/configure: Introduce deps on json-c lib for libxl Date: Fri, 8 Aug 2025 16:55:55 +0200 Message-Id: <20250808145602.41716-5-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754664995487124100 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD To replace yajl. Introduce YAJL_LIBS variable, to be able to remove "-lyajl" later. Signed-off-by: Anthony PERARD --- config/Tools.mk.in | 2 + tools/config.h.in | 3 ++ tools/configure | 107 +++++++++++++++++++++++++++++++++++++- tools/configure.ac | 6 ++- tools/libs/light/Makefile | 5 +- tools/xl/Makefile | 2 +- 6 files changed, 119 insertions(+), 6 deletions(-) diff --git a/config/Tools.mk.in b/config/Tools.mk.in index e47ac23d11..c2201021d1 100644 --- a/config/Tools.mk.in +++ b/config/Tools.mk.in @@ -65,6 +65,8 @@ EXTFS_LIBS :=3D @EXTFS_LIBS@ CURSES_LIBS :=3D @CURSES_LIBS@ TINFO_LIBS :=3D @TINFO_LIBS@ ARGP_LDFLAGS :=3D @argp_ldflags@ +LIBJSONC_LIBS :=3D @libjsonc_LIBS@ +YAJL_LIBS :=3D @YAJL_LIBS@ =20 FILE_OFFSET_BITS :=3D @FILE_OFFSET_BITS@ =20 diff --git a/tools/config.h.in b/tools/config.h.in index fe2a94cfc4..ed0042018d 100644 --- a/tools/config.h.in +++ b/tools/config.h.in @@ -27,6 +27,9 @@ /* Define to 1 if you have the `fdt' library (-lfdt). */ #undef HAVE_LIBFDT =20 +/* Use library json-c */ +#undef HAVE_LIBJSONC + /* Define to 1 if you have the `lzma' library (-llzma). */ #undef HAVE_LIBLZMA =20 diff --git a/tools/configure b/tools/configure index 5abd44e21e..edd1701b2d 100755 --- a/tools/configure +++ b/tools/configure @@ -660,6 +660,9 @@ libnl LIBNL3_LIBS LIBNL3_CFLAGS argp_ldflags +YAJL_LIBS +libjsonc_LIBS +libjsonc_CFLAGS PTHREAD_LIBS PTHREAD_LDFLAGS PTHREAD_CFLAGS @@ -882,6 +885,8 @@ pixman_CFLAGS pixman_LIBS libzstd_CFLAGS libzstd_LIBS +libjsonc_CFLAGS +libjsonc_LIBS LIBNL3_CFLAGS LIBNL3_LIBS SYSTEMD_SLEEP_DIR' @@ -1633,6 +1638,10 @@ Some influential environment variables: C compiler flags for libzstd, overriding pkg-config libzstd_LIBS linker flags for libzstd, overriding pkg-config + libjsonc_CFLAGS + C compiler flags for libjsonc, overriding pkg-config + libjsonc_LIBS + linker flags for libjsonc, overriding pkg-config LIBNL3_CFLAGS C compiler flags for LIBNL3, overriding pkg-config LIBNL3_LIBS linker flags for LIBNL3, overriding pkg-config @@ -9624,6 +9633,99 @@ printf "%s\n" "$ax_cv_pthread_flags" >&6; } =20 =20 =20 + +pkg_failed=3Dno +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libjsonc" >&5 +printf %s "checking for libjsonc... " >&6; } + +if test -n "$libjsonc_CFLAGS"; then + pkg_cv_libjsonc_CFLAGS=3D"$libjsonc_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists = --print-errors \"json-c\""; } >&5 + ($PKG_CONFIG --exists --print-errors "json-c") 2>&5 + ac_status=3D$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? =3D $ac_status" >&5 + test $ac_status =3D 0; }; then + pkg_cv_libjsonc_CFLAGS=3D`$PKG_CONFIG --cflags "json-c" 2>/dev/null` + test "x$?" !=3D "x0" && pkg_failed=3Dyes +else + pkg_failed=3Dyes +fi + else + pkg_failed=3Duntried +fi +if test -n "$libjsonc_LIBS"; then + pkg_cv_libjsonc_LIBS=3D"$libjsonc_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists = --print-errors \"json-c\""; } >&5 + ($PKG_CONFIG --exists --print-errors "json-c") 2>&5 + ac_status=3D$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? =3D $ac_status" >&5 + test $ac_status =3D 0; }; then + pkg_cv_libjsonc_LIBS=3D`$PKG_CONFIG --libs "json-c" 2>/dev/null` + test "x$?" !=3D "x0" && pkg_failed=3Dyes +else + pkg_failed=3Dyes +fi + else + pkg_failed=3Duntried +fi + + + +if test $pkg_failed =3D yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=3Dyes +else + _pkg_short_errors_supported=3Dno +fi + if test $_pkg_short_errors_supported =3D yes; then + libjsonc_PKG_ERRORS=3D`$PKG_CONFIG --short-errors --print-errors = --cflags --libs "json-c" 2>&1` + else + libjsonc_PKG_ERRORS=3D`$PKG_CONFIG --print-errors --cflags --libs= "json-c" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$libjsonc_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (json-c) were not met: + +$libjsonc_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables libjsonc_CFLAGS +and libjsonc_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed =3D untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. M= ake sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables libjsonc_CFLAGS +and libjsonc_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + libjsonc_CFLAGS=3D$pkg_cv_libjsonc_CFLAGS + libjsonc_LIBS=3D$pkg_cv_libjsonc_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + +printf "%s\n" "#define HAVE_LIBJSONC 1" >>confdefs.h + +fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for yajl_alloc in -= lyajl" >&5 printf %s "checking for yajl_alloc in -lyajl... " >&6; } if test ${ac_cv_lib_yajl_yajl_alloc+y} @@ -9661,9 +9763,10 @@ fi printf "%s\n" "$ac_cv_lib_yajl_yajl_alloc" >&6; } if test "x$ac_cv_lib_yajl_yajl_alloc" =3D xyes then : - printf "%s\n" "#define HAVE_LIBYAJL 1" >>confdefs.h + YAJL_LIBS=3D-lyajl =20 - LIBS=3D"-lyajl $LIBS" + +printf "%s\n" "#define HAVE_LIBYAJL 1" >>confdefs.h =20 else $as_nop as_fn_error $? "Could not find yajl" "$LINENO" 5 diff --git a/tools/configure.ac b/tools/configure.ac index dada1c3b15..bb40b5b3f0 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -424,7 +424,11 @@ AC_SUBST([ZLIB_CFLAGS]) AC_SUBST([ZLIB_LIBS]) AX_CHECK_EXTFS AX_CHECK_PTHREAD -AC_CHECK_LIB([yajl], [yajl_alloc], [], +PKG_CHECK_MODULES([libjsonc], [json-c], + [AC_DEFINE([HAVE_LIBJSONC], [1], [Use library json-c])]) +AC_CHECK_LIB([yajl], [yajl_alloc], + [AC_SUBST([YAJL_LIBS],[-lyajl]) + AC_DEFINE([HAVE_LIBYAJL],[1],[Define to 1 if you have the `yajl' libra= ry (-lyajl).])], [AC_MSG_ERROR([Could not find yajl])]) AC_CHECK_LIB([z], [deflateCopy], [], [AC_MSG_ERROR([Could not find zlib])]) AC_CHECK_HEADER([argp.h], [ diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile index b690d92159..fa2a338c2b 100644 --- a/tools/libs/light/Makefile +++ b/tools/libs/light/Makefile @@ -166,7 +166,8 @@ LDLIBS-$(CONFIG_Linux) +=3D -luuid LDLIBS-$(CONFIG_Linux) +=3D -lrt LDLIBS-$(CONFIG_ARM) +=3D -lfdt LDLIBS-y +=3D $(PTHREAD_LIBS) -LDLIBS-y +=3D -lyajl +LDLIBS-y +=3D $(YAJL_LIBS) +LDLIBS-y +=3D $(LIBJSONC_LIBS) LDLIBS +=3D $(LDLIBS-y) =20 $(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS): CFLAGS +=3D $(CFLAGS_LIBXL) -inc= lude $(XEN_ROOT)/tools/config.h @@ -246,7 +247,7 @@ libxenlight_test.so: $(PIC_OBJS) $(LIBXL_TEST_OBJS) $(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB= _LDFLAGS) -o $@ $^ $(LDLIBS) $(APPEND_LDFLAGS) =20 test_%: test_%.o test_common.o libxenlight_test.so - $(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenli= ght)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFL= AGS) + $(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenli= ght)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(YAJL_LIBS) $(LIBJS= ONC_LIBS) $(APPEND_LDFLAGS) =20 libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so $(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLI= BS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFL= AGS) diff --git a/tools/xl/Makefile b/tools/xl/Makefile index ad577cdd70..ff7a5aee94 100644 --- a/tools/xl/Makefile +++ b/tools/xl/Makefile @@ -33,7 +33,7 @@ $(XL_OBJS): CFLAGS +=3D -include $(XEN_ROOT)/tools/config= .h # libxl_json.h needs i all: xl =20 xl: $(XL_OBJS) - $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlig= ht) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) -lyajl $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlig= ht) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(YAJL_LIBS) $(LIBJSONC_L= IBS) $(APPEND_LDFLAGS) =20 .PHONY: install install: all --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664990; cv=none; d=zohomail.com; s=zohoarc; b=aeh5RglAPRi0q3f/4y99YwlBYfIk+Q/DkdTtBH9HEGzjO0bOhgRXRtLLXkU02Q0jjgW5/5N7JBxMEazOjAeqB/P3WOtXItgu7JOAk6xBUb2/txBcAmPt2A9Q9hLQ2I9xG+6sGGuvMK23qI8gYozdx1iNIO5kwJU7jy280lJ0mX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664990; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vRMIu2sOc8ho9gldf/0/Ow6xK9iiXJMrSVqeHIXyoNY=; b=h/7iTxEx8CADY0Gi8wFscjAuV5cJZjefdjZyKVt6acrelcD2H8Juqpj2VR7QPtTnxtTQkks2PQ8yu3+bf43UB9L9u0nDhdL5D96WJx3oIQ3KCiEd11xPwiBkDQaqp14zfQEd5HzmZg+99XUeIDLC+UvO4J5N2QzK/uy4pjIUYaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754664990200851.4748630750078; Fri, 8 Aug 2025 07:56:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074667.1437193 (Exim 4.92) (envelope-from ) id 1ukOVw-0000zb-1G; Fri, 08 Aug 2025 14:56:12 +0000 Received: by outflank-mailman (output) from mailman id 1074667.1437193; Fri, 08 Aug 2025 14:56:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVv-0000zO-RX; Fri, 08 Aug 2025 14:56:11 +0000 Received: by outflank-mailman (input) for mailman id 1074667; Fri, 08 Aug 2025 14:56:10 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVu-0000Vw-2P for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:10 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVt-007zrZ-2w; Fri, 08 Aug 2025 14:56:09 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVt-009BYT-27; Fri, 08 Aug 2025 14:56:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=vRMIu2sOc8ho9gldf/0/Ow6xK9iiXJMrSVqeHIXyoNY=; b=t4yE+O72N18PnGBjxjBJtEwsPG AJwQ4blV8QeBEnXfj/CRBe6ulEqOU7avsptKBYrpUqqwDxWoeUG2aRL52pVYjQbqZus/ABQHfha1B le4fknbkC8BPUG/OLy3CpFM2LykUbYxJM2CRzn1jVSOHCIrOhsSDXYZ2EhvRypjnSSqI=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Juergen Gross Subject: [XEN PATCH 05/11] libxl: Convert libxl__json_parse() to use json-c Date: Fri, 8 Aug 2025 16:55:56 +0200 Message-Id: <20250808145602.41716-6-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754664990783116600 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD This reuse the "json_callback_*" implemented for the yajl parser as they don't really need to be changed. It's just awkward to have to cast between `unsigned char` and `char.` Replace few strncpy() by memcpy() to let the compiler know we want to copy the string without the terminating nul, as we are adding it just after. Also, it should be possible to keep using YAJL parser when json-c library isn't available. Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/include/libxl_json.h | 4 ++ tools/libs/light/libxl_json.c | 120 ++++++++++++++++++++++++++++++++-- 2 files changed, 120 insertions(+), 4 deletions(-) diff --git a/tools/include/libxl_json.h b/tools/include/libxl_json.h index 3f97267eae..f0b4871e0e 100644 --- a/tools/include/libxl_json.h +++ b/tools/include/libxl_json.h @@ -42,6 +42,7 @@ yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen hand,= libxl_ms_vm_genid *p); # define HAVE_YAJL_V2 1 #endif =20 +#ifdef HAVE_LIBYAJL #ifdef HAVE_YAJL_V2 =20 typedef size_t libxl_yajl_length; @@ -89,5 +90,8 @@ static inline yajl_gen libxl_yajl_gen_alloc(const yajl_al= loc_funcs *allocFuncs) } =20 #endif /* !HAVE_YAJL_V2 */ +#else +typedef size_t libxl_yajl_length; +#endif /* !HAVE_LIBYAJL */ =20 #endif /* LIBXL_JSON_H */ diff --git a/tools/libs/light/libxl_json.c b/tools/libs/light/libxl_json.c index 9b8ef2cab9..44ee6e213f 100644 --- a/tools/libs/light/libxl_json.c +++ b/tools/libs/light/libxl_json.c @@ -16,7 +16,25 @@ =20 #include =20 +#ifdef HAVE_LIBJSONC +#include +#define USE_LIBJSONC_PARSER +#endif + +#ifdef HAVE_LIBYAJL +# ifndef USE_LIBJSONC_PARSER +# define USE_LIBYAJL_PARSER +# endif +#endif + + +#ifdef USE_LIBJSONC_PARSER +#include +#endif + +#ifdef USE_LIBYAJL_PARSER #include +#endif #include =20 #include "libxl_internal.h" @@ -25,7 +43,9 @@ =20 typedef struct libxl__yajl_ctx { libxl__gc *gc; +#ifdef USE_LIBYAJL_PARSER yajl_handle hand; +#endif libxl__json_object *head; libxl__json_object *current; #ifdef DEBUG_ANSWER @@ -33,7 +53,7 @@ typedef struct libxl__yajl_ctx { #endif } libxl__yajl_ctx; =20 -#ifdef DEBUG_ANSWER +#if defined(DEBUG_ANSWER) && defined(USE_LIBYAJL_PARSER) #if YAJL_VERSION < 20000 # define DEBUG_GEN_ALLOC(ctx) \ if ((ctx)->g =3D=3D NULL) { \ @@ -759,7 +779,7 @@ static int json_callback_number(void *opaque, const cha= r *s, libxl_yajl_length l obj =3D libxl__json_object_alloc(ctx->gc, JSON_NUMBER); =20 t =3D libxl__zalloc(ctx->gc, len + 1); - strncpy(t, s, len); + memcpy(t, s, len); t[len] =3D 0; =20 obj->u.string =3D t; @@ -806,7 +826,7 @@ static int json_callback_map_key(void *opaque, const un= signed char *str, =20 DEBUG_GEN_STRING(ctx, str, len); =20 - strncpy(t, (const char *) str, len); + memcpy(t, (const char *) str, len); t[len] =3D 0; =20 if (libxl__json_object_is_map(obj)) { @@ -890,6 +910,7 @@ static int json_callback_end_array(void *opaque) return 1; } =20 +#ifdef USE_LIBYAJL_PARSER static yajl_callbacks callbacks =3D { json_callback_null, json_callback_boolean, @@ -903,28 +924,111 @@ static yajl_callbacks callbacks =3D { json_callback_start_array, json_callback_end_array }; +#endif =20 static void yajl_ctx_free(libxl__yajl_ctx *yajl_ctx) { +#ifdef USE_LIBYAJL_PARSER if (yajl_ctx->hand) { yajl_free(yajl_ctx->hand); yajl_ctx->hand =3D NULL; } +#endif DEBUG_GEN_FREE(yajl_ctx); } =20 +#ifdef USE_LIBJSONC_PARSER +static int jso_visiter(json_object *jso, + int flags, + json_object *parent_jso, + const char *jso_key, + size_t *jso_index, + void *userarg) +{ + enum json_type type; + int r; + + if (jso_key && flags !=3D JSON_C_VISIT_SECOND) { + json_callback_map_key(userarg, (const unsigned char*)jso_key, strl= en(jso_key)); + } + type =3D json_object_get_type(jso); + switch (type) { + case json_type_null: + r =3D json_callback_null(userarg); + break; + case json_type_boolean: + r =3D json_callback_boolean(userarg, json_object_get_boolean(jso)); + break; + case json_type_int: + case json_type_double: { + // it might be better to use on of + // json_object_get_{int,int64,uint64,double} instead. + // but would need to replace json_callback_number(). + const char *s =3D json_object_get_string(jso); + r =3D json_callback_number(userarg, s, strlen(s)); + break; + } + case json_type_object: + if (flags !=3D JSON_C_VISIT_SECOND) { + r =3D json_callback_start_map(userarg); + } else { + r =3D json_callback_end_map(userarg); + } + break; + case json_type_array: + if (flags !=3D JSON_C_VISIT_SECOND) { + r =3D json_callback_start_array(userarg); + } else { + r =3D json_callback_end_array(userarg); + } + break; + case json_type_string: { + const char *s =3D json_object_get_string(jso); + const int len =3D json_object_get_string_len(jso); + r =3D json_callback_string(userarg, (const unsigned char*)s, len); + break; + } + default: + /* error */ + r =3D 0; + } + if (r =3D=3D 0) + return JSON_C_VISIT_RETURN_ERROR; + return JSON_C_VISIT_RETURN_CONTINUE; +} +#endif + libxl__json_object *libxl__json_parse(libxl__gc *gc, const char *s) { +#ifdef USE_LIBYAJL_PARSER yajl_status status; + unsigned char *str =3D NULL; +#endif libxl__yajl_ctx yajl_ctx; libxl__json_object *o =3D NULL; - unsigned char *str =3D NULL; +#ifdef USE_LIBJSONC_PARSER + json_object *jso; + enum json_tokener_error error; + + jso =3D json_tokener_parse_verbose(s, &error); + if (!jso) { + LOG(ERROR, "json-c parse error: %s", json_tokener_error_desc(error= )); + goto out; + } +#endif =20 memset(&yajl_ctx, 0, sizeof (yajl_ctx)); yajl_ctx.gc =3D gc; =20 DEBUG_GEN_ALLOC(&yajl_ctx); =20 +#ifdef USE_LIBJSONC_PARSER + int r =3D json_c_visit(jso, 0, jso_visiter, &yajl_ctx); + if (r < 0) { + LOG(ERROR, "json_c_visit failed"); + goto out; + } +#elif defined(USE_LIBYAJL_PARSER) if (yajl_ctx.hand =3D=3D NULL) { yajl_ctx.hand =3D libxl__yajl_alloc(&callbacks, NULL, &yajl_ctx); } @@ -935,6 +1039,7 @@ libxl__json_object *libxl__json_parse(libxl__gc *gc, c= onst char *s) status =3D yajl_complete_parse(yajl_ctx.hand); if (status !=3D yajl_status_ok) goto out; +#endif =20 o =3D yajl_ctx.head; =20 @@ -943,13 +1048,20 @@ libxl__json_object *libxl__json_parse(libxl__gc *gc,= const char *s) yajl_ctx.head =3D NULL; =20 yajl_ctx_free(&yajl_ctx); +#ifdef USE_LIBJSONC_PARSER + json_object_put(jso); +#endif return o; =20 out: +#ifdef USE_LIBJSONC_PARSER + json_object_put(jso); +#elif defined(USE_LIBYAJL_PARSER) str =3D yajl_get_error(yajl_ctx.hand, 1, (const unsigned char*)s, strl= en(s)); =20 LIBXL__LOG(libxl__gc_owner(gc), LIBXL__LOG_ERROR, "yajl error: %s", st= r); yajl_free_error(yajl_ctx.hand, str); +#endif yajl_ctx_free(&yajl_ctx); return NULL; } --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664999; cv=none; d=zohomail.com; s=zohoarc; b=SHGIdJnTueDkXpTVjuAdZvqInCGuESCyB4JB4IEMk/SOU5NYRvMyrJprDKPQvoQHvEGU+pHplerfEHCxrMiGovyZ4pF12fe2XSaBb5VqrA8ZR2kYg/szjL02mb4Gn3z4vg/Qm/bGOBUvg/X9vKLxkwfLqeq5+YHsebvj5aqe02o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664999; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dcQEIpjSqwJNNN97D3SvCHSjmd4l+W6ydBENkrkkG8A=; b=N2D0FgYylHHuWw89Dja4Pu9J6NiLEhRbQyCZx+T/bdnKDF4+VMGrCB2Ohldqw3XUX9bQJ/lYAZmIQUSebGPKJ9Hmgpf1C3hrOZZlrFv6t6js1SSa3QjC5gaamHv87us4fID5MtlpQGeJ7iic3HRQ+5zjPNXxER/En6r4U/apjNI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754664999346593.467503287354; Fri, 8 Aug 2025 07:56:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074668.1437198 (Exim 4.92) (envelope-from ) id 1ukOVw-00012t-Df; Fri, 08 Aug 2025 14:56:12 +0000 Received: by outflank-mailman (output) from mailman id 1074668.1437198; Fri, 08 Aug 2025 14:56:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVw-00012F-6Q; Fri, 08 Aug 2025 14:56:12 +0000 Received: by outflank-mailman (input) for mailman id 1074668; Fri, 08 Aug 2025 14:56:10 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVu-0000jH-TS for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:10 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVu-007zrg-2R; Fri, 08 Aug 2025 14:56:10 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVu-009BYT-1b; Fri, 08 Aug 2025 14:56:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=dcQEIpjSqwJNNN97D3SvCHSjmd4l+W6ydBENkrkkG8A=; b=Cw5C3xDkqxHQcoGogOzp/+nHqW ipjba7VAEVJg5anvNy3oWv9WrAU+B43l7G0LdueLHvsMGz+VNsUAQvdMrIWuGV7npIp6jpMsbNgyy 2jzZQUXqdL1I04AewWTPHLc41suIZqC3XevLJaeinEcFp/wNRugjE1Gsr0Sj5W1ea98c=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Juergen Gross Subject: [XEN PATCH 06/11] libxl: convert libxl__json_object_to_yajl_gen to libxl__json_object_to_libjsonc_object Date: Fri, 8 Aug 2025 16:55:57 +0200 Message-Id: <20250808145602.41716-7-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754665001813124100 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD Convert yajl_gen to json_object from lib json-c. And make use of it in qmp_prepare_cmd(), which can be compiled with either lib. Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/include/libxl_json.h | 6 ++ tools/libs/light/libxl_internal.h | 7 +++ tools/libs/light/libxl_json.c | 95 +++++++++++++++++++++++++++++++ tools/libs/light/libxl_qmp.c | 53 +++++++++++++++++ 4 files changed, 161 insertions(+) diff --git a/tools/include/libxl_json.h b/tools/include/libxl_json.h index f0b4871e0e..e2ef8151f0 100644 --- a/tools/include/libxl_json.h +++ b/tools/include/libxl_json.h @@ -15,12 +15,18 @@ #ifndef LIBXL_JSON_H #define LIBXL_JSON_H =20 +#ifdef HAVE_LIBJSONC +#include +#endif + +#ifdef HAVE_LIBYAJL #include #include =20 #ifdef HAVE_YAJL_YAJL_VERSION_H # include #endif +#endif =20 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); diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 4b6587a27a..b66aaa779d 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -2234,9 +2234,16 @@ _hidden const libxl__json_object *libxl__json_map_ge= t(const char *key, */ _hidden libxl__json_object *libxl__json_object_alloc(libxl__gc *gc_opt, libxl__json_node_type= type); +#ifdef HAVE_LIBJSONC +_hidden int libxl__json_object_to_json_object(libxl__gc *gc, + json_object **jso_out, + const libxl__json_object *ob= j); +#endif +#ifdef HAVE_LIBYAJL _hidden yajl_status libxl__json_object_to_yajl_gen(libxl__gc *gc_opt, yajl_gen hand, const libxl__json_objec= t *param); +#endif _hidden void libxl__json_object_free(libxl__gc *gc_opt, libxl__json_object *obj); =20 diff --git a/tools/libs/light/libxl_json.c b/tools/libs/light/libxl_json.c index 44ee6e213f..b26ac901d6 100644 --- a/tools/libs/light/libxl_json.c +++ b/tools/libs/light/libxl_json.c @@ -631,6 +631,100 @@ const libxl__json_object *libxl__json_map_get(const c= har *key, return NULL; } =20 +#ifdef HAVE_LIBJSONC +int libxl__json_object_to_json_object(libxl__gc *gc, + json_object **jso_out, + const libxl__json_object *obj) +{ + int idx =3D 0; + int rc, r; + + switch (obj->type) { + case JSON_NULL: + *jso_out =3D json_object_new_null(); + return 0; + case JSON_BOOL: + *jso_out =3D json_object_new_boolean(obj->u.b); + if (!*jso_out) + return ERROR_NOMEM; + return 0; + case JSON_INTEGER: + *jso_out =3D json_object_new_int64(obj->u.i); + if (!*jso_out) + return ERROR_NOMEM; + return 0; + case JSON_DOUBLE: + *jso_out =3D json_object_new_double(obj->u.d); + if (!*jso_out) + return ERROR_NOMEM; + return 0; + case JSON_NUMBER: + *jso_out =3D json_object_new_string(obj->u.string); + if (!*jso_out) + return ERROR_NOMEM; + return 0; + case JSON_STRING: + *jso_out =3D json_object_new_string(obj->u.string); + if (!*jso_out) + return ERROR_NOMEM; + return 0; + case JSON_MAP: { + libxl__json_map_node *node =3D NULL; + json_object *map_root =3D json_object_new_object(); + json_object *node_value; + + for (idx =3D 0; idx < obj->u.map->count; idx++) { + if (flexarray_get(obj->u.map, idx, (void**)&node) !=3D 0) + break; + + rc =3D libxl__json_object_to_json_object(gc, &node_value, node= ->obj); + if (rc) { + json_object_put(map_root); + return rc; + } + + r =3D json_object_object_add(map_root, node->map_key, node_val= ue); + if (r < 0) { + json_object_put(node_value); + json_object_put(map_root); + return ERROR_FAIL; + } + } + *jso_out =3D map_root; + return 0; + } + case JSON_ARRAY: { + libxl__json_object *node =3D NULL; + json_object *array_root =3D json_object_new_array_ext(obj->u.array= ->count); + json_object *node_value; + + for (idx =3D 0; idx < obj->u.array->count; idx++) { + if (flexarray_get(obj->u.array, idx, (void**)&node) !=3D 0) + break; + + rc =3D libxl__json_object_to_json_object(gc, &node_value, node= ); + if (rc) { + json_object_put(array_root); + return rc; + } + r =3D json_object_array_add(array_root, node_value); + if (r < 0) { + json_object_put(node_value); + json_object_put(array_root); + return ERROR_FAIL; + } + } + *jso_out =3D array_root; + return 0; + } + case JSON_ANY: + default: + /* JSON_ANY is not a valid value for obj->type. */ + return ERROR_FAIL; + } +} +#endif +#ifdef HAVE_LIBYAJL yajl_status libxl__json_object_to_yajl_gen(libxl__gc *gc, yajl_gen hand, const libxl__json_object *obj) @@ -698,6 +792,7 @@ yajl_status libxl__json_object_to_yajl_gen(libxl__gc *g= c, abort(); #undef CONVERT_YAJL_GEN_TO_STATUS } +#endif =20 =20 /* diff --git a/tools/libs/light/libxl_qmp.c b/tools/libs/light/libxl_qmp.c index 84740bd4b3..94b6fdb559 100644 --- a/tools/libs/light/libxl_qmp.c +++ b/tools/libs/light/libxl_qmp.c @@ -61,7 +61,11 @@ =20 #include =20 +#ifdef HAVE_LIBJSONC +#include +#elif defined(HAVE_LIBYAJL) #include +#endif =20 #include "xen_list.h" #include "libxl_internal.h" @@ -481,13 +485,56 @@ static char *qmp_prepare_cmd(libxl__gc *gc, const cha= r *cmd, const libxl__json_object *args, int id) { +#ifdef HAVE_LIBJSONC + json_object *jso =3D NULL; + json_object *jso_value =3D NULL; + /* memory for 'buf' is owned by 'jso' */ + const char *buf; + int rc, r; +#elif defined(HAVE_LIBYAJL) yajl_gen hand =3D NULL; /* memory for 'buf' is owned by 'hand' */ const unsigned char *buf; libxl_yajl_length len; yajl_gen_status s; +#else +# error Missing JSON library +#endif char *ret =3D NULL; =20 +#ifdef HAVE_LIBJSONC + jso =3D json_object_new_object(); + if (!jso) + goto out; + + jso_value =3D json_object_new_string(cmd); + if (!jso_value) + goto out; + r =3D json_object_object_add(jso, "execute", jso_value); + if (r < 0) + goto out; + jso_value =3D json_object_new_int(id); + if (!jso_value) + goto out; + r =3D json_object_object_add(jso, "id", jso_value); + if (r < 0) + goto out; + /* `jso_value` now part of `jso`, shouldn't free it anymore */ + jso_value =3D NULL; + if (args) { + rc =3D libxl__json_object_to_json_object(gc, &jso_value, args); + if (rc) + goto out; + r =3D json_object_object_add(jso, "arguments", jso_value); + if (r < 0) + goto out; + jso_value =3D NULL; + } + + buf =3D json_object_to_json_string_ext(jso, JSON_C_TO_STRING_PLAIN); + ret =3D libxl__sprintf(gc, "%s\r\n", buf); + +#elif defined(HAVE_LIBYAJL) hand =3D libxl_yajl_gen_alloc(NULL); =20 if (!hand) { @@ -516,9 +563,15 @@ static char *qmp_prepare_cmd(libxl__gc *gc, const char= *cmd, goto out; =20 ret =3D libxl__sprintf(gc, "%*.*s\r\n", (int)len, (int)len, buf); +#endif =20 out: +#ifdef HAVE_LIBJSONC + json_object_put(jso_value); + json_object_put(jso); +#elif defined(HAVE_LIBYAJL) yajl_gen_free(hand); +#endif return ret; } =20 --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664988; cv=none; d=zohomail.com; s=zohoarc; b=MA6iowAVr9FABLEaGzE7/fveKPOrPmsrTPVHza1J6E6oNtlGmbctZ5kbSBeZ5MG3U46Wm/4gO5ze/HJHAjE6ulNz1O2ovF0+QiBIyA/BT8Nf5nLx+cTZPqJLcqoiHd0MaeU46owMKMzfcgZKAkooSqzAaQXauhInv/mDwF9YkOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664988; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yNC5zIuniXe7MpzZB+le6KyA7cchPYRApjLfmWNgdQA=; b=jNuZGQ1Rz63zOn0QO75kBx/XbbadrqWYmNmGcfFOXFg+DgTlT9agfS9LlQUYyc211oDYEMDTK6fT2DsIRrGLaXWDORAwylRgKgOOmZ/jqgINVIrlXCqS1eL87astXAw2OH/dt6DCf88b3NewjGQaXpugYeNuFRU7IntpvJ114KI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754664988526610.5175494836683; Fri, 8 Aug 2025 07:56:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074669.1437213 (Exim 4.92) (envelope-from ) id 1ukOVy-0001Uy-1a; Fri, 08 Aug 2025 14:56:14 +0000 Received: by outflank-mailman (output) from mailman id 1074669.1437213; Fri, 08 Aug 2025 14:56:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVx-0001Th-SZ; Fri, 08 Aug 2025 14:56:13 +0000 Received: by outflank-mailman (input) for mailman id 1074669; Fri, 08 Aug 2025 14:56:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVv-000100-UR for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:11 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVv-007zrm-2N; Fri, 08 Aug 2025 14:56:11 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVv-009BYT-19; Fri, 08 Aug 2025 14:56:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=yNC5zIuniXe7MpzZB+le6KyA7cchPYRApjLfmWNgdQA=; b=sUuj1GM1OiRkIHneldzZWNnwRd XwX6R4WEoiomSYj258RbMc9CloFHj86mTWfCEbFyVuKtGTwNcOPHq5Qy9yN/M7EKA9mFzsPgz8hSX Hdmi8D0ovaRa9B6p1IXZrQNxAroIngYnVUlXzDCC9O5ce+X/FXv6KYbLdbQJ7gKoBLcI=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Juergen Gross Subject: [XEN PATCH 07/11] libxl: libxl__object_to_json() to json-c Date: Fri, 8 Aug 2025 16:55:58 +0200 Message-Id: <20250808145602.41716-8-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754664989606124100 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD - 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 Reviewed-by: Jason Andryuk --- tools/include/libxl_json.h | 17 ++ tools/libs/light/Makefile | 2 +- tools/libs/light/gentypes.py | 160 ++++++++++- tools/libs/light/idl.py | 7 +- tools/libs/light/libxl_cpuid.c | 119 ++++++++ tools/libs/light/libxl_internal.h | 16 +- tools/libs/light/libxl_json.c | 316 ++++++++++++++++++++++ tools/libs/light/libxl_types.idl | 7 +- tools/libs/light/libxl_types_internal.idl | 3 +- tools/xl/xl_info.c | 102 ++++++- 10 files changed, 729 insertions(+), 20 deletions(-) diff --git a/tools/include/libxl_json.h b/tools/include/libxl_json.h index e2ef8151f0..c130e88a5e 100644 --- a/tools/include/libxl_json.h +++ b/tools/include/libxl_json.h @@ -28,6 +28,22 @@ #endif #endif =20 +#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_cpui= d_policy_list *p); +_hidden int libxl_string_list_gen_jso(json_object **jso_r,libxl_string_lis= t *p); +_hidden int libxl_key_value_list_gen_jso(json_object **jso_r, libxl_key_va= lue_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_gen= id *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 ha= nd, 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_geni= d *p); +#endif =20 #include <_libxl_types_json.h> =20 diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile index fa2a338c2b..c59c2cf198 100644 --- a/tools/libs/light/Makefile +++ b/tools/libs/light/Makefile @@ -227,7 +227,7 @@ testidl.o: $(XEN_INCLUDE)/libxl.h # This exploits the 'multi-target pattern rule' trick. # gentypes.py should be executed only once to make all the targets. _libxl_type%.h _libxl_type%_json.h _libxl_type%_private.h _libxl_type%.c: = libxl_type%.idl gentypes.py idl.py - $(PYTHON) gentypes.py libxl_type$(*F).idl __libxl_type$(*F).h __libxl_typ= e$(*F)_private.h \ + $(PYTHON) gentypes.py $(if $(LIBJSONC_LIBS),--libjsonc) libxl_type$(*F).i= dl __libxl_type$(*F).h __libxl_type$(*F)_private.h \ __libxl_type$(*F)_json.h __libxl_type$(*F).c $(call move-if-changed,__libxl_type$(*F).h,_libxl_type$(*F).h) $(call move-if-changed,__libxl_type$(*F)_private.h,_libxl_type$(*F)_priva= te.h) diff --git a/tools/libs/light/gentypes.py b/tools/libs/light/gentypes.py index 3fe3873242..006bea170a 100644 --- a/tools/libs/light/gentypes.py +++ b/tools/libs/light/gentypes.py @@ -256,6 +256,30 @@ def libxl_C_type_member_init(ty, field): s +=3D "\n" return s =20 +# For json-c gen_jso functions +def libxl_C_type_gen_jso_map_key(f, parent, indent, scope_object, sub_scop= e_object): + s =3D "" + if isinstance(f.type, idl.KeyedUnion): + s +=3D "switch (%s) {\n" % (parent + f.type.keyvar.name) + for x in f.type.fields: + v =3D f.type.keyvar.name + "." + x.name + s +=3D "case %s:\n" % x.enumname + s +=3D " if (json_object_object_add(%s, \"%s\", %s)) {\n" %= (scope_object, v, sub_scope_object) + s +=3D " json_object_put(%s);\n" % (sub_scope_object) + s +=3D " goto out;\n" + s +=3D " }\n" + s +=3D " break;\n" + s +=3D "}\n" + else: + s +=3D "if (json_object_object_add(%s, \"%s\", %s)) {\n" % (scope_= object, f.name, sub_scope_object) + s +=3D " json_object_put(%s);\n" % (sub_scope_object) + s +=3D " goto out;\n" + s +=3D "}\n" + if s !=3D "": + s =3D indent + s + return s.replace("\n", "\n%s" % indent).rstrip(indent) + +# For YAJL gen_json functions def libxl_C_type_gen_map_key(f, parent, indent =3D ""): s =3D "" if isinstance(f.type, idl.KeyedUnion): @@ -352,6 +376,86 @@ def get_default_expr(f, nparent, fexpr): =20 return "%s" % fexpr =20 +# For json-c gen_json functions +def libxl_C_type_gen_jso(ty, v, indent =3D " ", parent =3D None, scope_= object =3D "jso"): + s =3D "" + if parent is None: + s +=3D "json_object *jso;\n" + s +=3D "int rc;\n" + sub_scope_object =3D "jso_sub_1" + else: + sub_scope_object =3D "jso_sub_%d" % (1+int(scope_object.removepref= ix("jso_sub_"))) + + if isinstance(ty, idl.Array): + if parent is None: + raise Exception("Array type must have a parent") + s +=3D "{\n" + s +=3D " int i;\n" + s +=3D " %s =3D json_object_new_array_ext(%s);\n" % (scope_obje= ct, parent + ty.lenvar.name) + s +=3D " if (!%s)\n" % (scope_object) + s +=3D " goto out;\n" + s +=3D " for (i=3D0; i<%s; i++) {\n" % (parent + ty.lenvar.name) + s +=3D " json_object *%s;\n" % (sub_scope_object) + # remove some indent, it's over indented at least in one case libx= l_vcpu_sched_params_gen_json + s +=3D libxl_C_type_gen_jso(ty.elem_type, v+"[i]", + indent + " ", parent, sub_scope_obje= ct) + s +=3D " if (json_object_array_add(%s, %s)) {\n" % (scope_o= bject, sub_scope_object) + s +=3D " json_object_put(%s);\n" % (sub_scope_object) + s +=3D " goto out;\n" + s +=3D " }\n" + s +=3D " }\n" + s +=3D "}\n" + elif isinstance(ty, idl.Enumeration): + s +=3D "rc =3D libxl__enum_gen_jso(&%s, %s_to_string(%s));\n" % (s= cope_object, ty.typename, ty.pass_arg(v, parent is None)) + s +=3D "if (rc)\n" + s +=3D " goto out;\n" + elif isinstance(ty, idl.KeyedUnion): + if parent is None: + raise Exception("KeyedUnion type must have a parent") + s +=3D "switch (%s) {\n" % (parent + ty.keyvar.name) + for f in ty.fields: + (nparent,fexpr) =3D ty.member(v, f, parent is None) + s +=3D "case %s:\n" % f.enumname + if f.type is not None: + s +=3D libxl_C_type_gen_jso(f.type, fexpr, indent + " "= , nparent, scope_object) + else: + s +=3D " %s =3D json_object_new_object();\n" % (scope_o= bject) + s +=3D " if (!%s)\n" % (scope_object) + s +=3D " goto out;\n" + s +=3D " break;\n" + s +=3D "}\n" + elif isinstance(ty, idl.Struct) and (parent is None or ty.json_gen_fn = is None): + s +=3D "%s =3D json_object_new_object();\n" % (scope_object) + s +=3D "if (!%s)\n" % (scope_object) + s +=3D " goto out;\n" + for f in [f for f in ty.fields if not f.const and not f.type.priva= te]: + (nparent,fexpr) =3D ty.member(v, f, parent is None) + default_expr =3D get_default_expr(f, nparent, fexpr) + s +=3D "if (%s) {\n" % default_expr + s +=3D " json_object *%s =3D NULL;\n" % (sub_scope_object) + s +=3D libxl_C_type_gen_jso(f.type, fexpr, " ", nparent, su= b_scope_object) + s +=3D libxl_C_type_gen_jso_map_key(f, nparent, " ", scope_= object, sub_scope_object) + + s +=3D "}\n" + + else: + if ty.json_gen_fn is not None: + s +=3D "rc =3D %s(&%s, %s);\n" % (ty.json_gen_fn, scope_object= , ty.pass_arg(v, parent is None)) + s +=3D "if (rc)\n" + s +=3D " goto out;\n" + + if parent is None: + s +=3D "*jso_r =3D jso;\n" + s +=3D "return 0;\n" + s +=3D "out:\n" + s +=3D "json_object_put(jso);\n" + s +=3D "return ERROR_FAIL;\n" + + if s !=3D "": + s =3D indent + s + return s.replace("\n", "\n%s" % indent).rstrip(indent) + +# For YAJL gen_json functions def libxl_C_type_gen_json(ty, v, indent =3D " ", parent =3D None): s =3D "" if parent is None: @@ -426,9 +530,9 @@ def libxl_C_type_gen_json(ty, v, indent =3D " ", par= ent =3D None): s =3D indent + s return s.replace("\n", "\n%s" % indent).rstrip(indent) =20 -def libxl_C_type_to_json(ty, v, indent =3D " "): +def libxl_C_type_to_json(ty, v, indent =3D " ", fn_ptr_type=3D"libxl__g= en_json_callback", fn_suffix=3D"_gen_json"): s =3D "" - gen =3D "(libxl__gen_json_callback)&%s_gen_json" % ty.typename + gen =3D "(%s)&%s%s" % (fn_ptr_type, ty.typename, fn_suffix) s +=3D "return libxl__object_to_json(ctx, \"%s\", %s, (void *)%s);\n" = % (ty.typename, gen, ty.pass_arg(v, passby=3Didl.PASS_BY_REFERENCE)) =20 if s !=3D "": @@ -589,14 +693,38 @@ def clean_header_define(header_path): =20 =20 if __name__ =3D=3D '__main__': + opt_libjsonc =3D False + if len(sys.argv) =3D=3D 7: + if sys.argv.pop(1) =3D=3D "--libjsonc": + opt_libjsonc =3D True if len(sys.argv) !=3D 6: print("Usage: gentypes.py
", file=3Dsys.stderr) sys.exit(1) =20 (_, idlname, header, header_private, header_json, impl) =3D sys.argv =20 + # Overwrite `json_gen_fn` for standard types + if opt_libjsonc: + idl.bool.json_gen_fn =3D "libxl__boolean_gen_jso" + idl.size_t.json_gen_fn =3D "libxl__int_gen_jso" + idl.integer .json_gen_fn =3D "libxl__int_gen_jso" + idl.uint8.json_gen_fn =3D "libxl__int_gen_jso" + idl.uint16.json_gen_fn =3D "libxl__int_gen_jso" + idl.uint32.json_gen_fn =3D "libxl__int_gen_jso" + idl.uint64.json_gen_fn =3D "libxl__uint64_gen_jso" + idl.string.json_gen_fn =3D "libxl__string_gen_jso" + (builtins,types) =3D idl.parse(idlname) =20 + # Overwrite `json_gen_fn` with `jsonc_json_gen_fn` for types from the = IDL + if opt_libjsonc: + for t in builtins: + if t.jsonc_json_gen_fn is not None: + t.json_gen_fn =3D t.jsonc_json_gen_fn + for t in types: + if t.jsonc_json_gen_fn is not None: + t.json_gen_fn =3D t.jsonc_json_gen_fn + print("outputting libxl type definitions to %s" % header) =20 f =3D open(header, "w") @@ -665,7 +793,11 @@ if __name__ =3D=3D '__main__': """ % (header_json_define, header_json_define, " ".join(sys.argv))) =20 for ty in [ty for ty in types if ty.json_gen_fn is not None]: - f.write("%syajl_gen_status %s_gen_json(yajl_gen hand, %s);\n" % (t= y.hidden(), ty.typename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENCE))) + if opt_libjsonc: + # Always hide JSON generators base on json-c + f.write("%sint %s_gen_jso(json_object **jso_r, %s);\n" % ("_hi= dden ", ty.typename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENCE))) + else: + f.write("%syajl_gen_status %s_gen_json(yajl_gen hand, %s);\n" = % (ty.hidden(), ty.typename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENC= E))) =20 f.write("\n") f.write("""#endif /* %s */\n""" % header_json_define) @@ -769,15 +901,25 @@ if __name__ =3D=3D '__main__': f.write("\n") =20 for ty in [t for t in types if t.json_gen_fn is not None]: - f.write("yajl_gen_status %s_gen_json(yajl_gen hand, %s)\n" % (ty.t= ypename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENCE))) - f.write("{\n") - f.write(libxl_C_type_gen_json(ty, "p")) - f.write("}\n") - f.write("\n") + if opt_libjsonc: + f.write("int %s_gen_jso(json_object **jso_r, %s)\n" % (ty.type= name, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENCE))) + f.write("{\n") + f.write(libxl_C_type_gen_jso(ty, "p")) + f.write("}\n") + f.write("\n") + else: + f.write("yajl_gen_status %s_gen_json(yajl_gen hand, %s)\n" % (= ty.typename, ty.make_arg("p", passby=3Didl.PASS_BY_REFERENCE))) + f.write("{\n") + f.write(libxl_C_type_gen_json(ty, "p")) + f.write("}\n") + f.write("\n") =20 f.write("char *%s_to_json(libxl_ctx *ctx, %s)\n" % (ty.typename, t= y.make_arg("p"))) f.write("{\n") - f.write(libxl_C_type_to_json(ty, "p")) + if opt_libjsonc: + f.write(libxl_C_type_to_json(ty, "p", fn_ptr_type=3D"libxl__ge= n_json_callback", fn_suffix=3D"_gen_jso")) + else: + f.write(libxl_C_type_to_json(ty, "p", fn_ptr_type=3D"libxl__ge= n_json_callback", fn_suffix=3D"_gen_json")) f.write("}\n") f.write("\n") =20 diff --git a/tools/libs/light/idl.py b/tools/libs/light/idl.py index d7367503b4..61c8e14004 100644 --- a/tools/libs/light/idl.py +++ b/tools/libs/light/idl.py @@ -79,6 +79,7 @@ class Type(object): =20 if self.typename is not None and not self.private: self.json_gen_fn =3D kwargs.setdefault('json_gen_fn', self.typ= ename + "_gen_json") + self.jsonc_json_gen_fn =3D kwargs.setdefault('jsonc_json_gen_f= n', self.typename + "_gen_jso") self.json_parse_type =3D kwargs.setdefault('json_parse_type', = "JSON_ANY") if self.namespace is not None: self.json_parse_fn =3D kwargs.setdefault('json_parse_fn', @@ -88,6 +89,7 @@ class Type(object): self.typename + "_p= arse_json") else: self.json_gen_fn =3D kwargs.setdefault('json_gen_fn', None) + self.jsonc_json_gen_fn =3D kwargs.setdefault('jsonc_json_gen_f= n', None) self.json_parse_type =3D kwargs.setdefault('json_parse_type', = None) self.json_parse_fn =3D kwargs.setdefault('json_parse_fn', None) =20 @@ -142,6 +144,7 @@ class Number(Builtin): kwargs.setdefault('copy_fn', None) kwargs.setdefault('signed', False) kwargs.setdefault('json_gen_fn', "yajl_gen_integer") + kwargs.setdefault('jsonc_json_gen_fn', "libxl__int_gen_jso") kwargs.setdefault('json_parse_type', "JSON_INTEGER") # json_parse_fn might be overriden on specific type kwargs.setdefault('json_parse_fn', "libxl__int_parse_json") @@ -290,6 +293,7 @@ void =3D Builtin("void *", namespace =3D None) bool =3D Builtin("bool", namespace =3D None, copy_fn=3DNone, json_gen_fn =3D "yajl_gen_bool", + jsonc_json_gen_fn =3D "libxl__boolean_gen_jso", json_parse_type =3D "JSON_BOOL", json_parse_fn =3D "libxl__bool_parse_json", autogenerate_json =3D False) @@ -301,10 +305,11 @@ integer =3D Number("int", namespace =3D None, signed = =3D True) uint8 =3D UInt(8) uint16 =3D UInt(16) uint32 =3D UInt(32) -uint64 =3D UInt(64, json_gen_fn =3D "libxl__uint64_gen_json") +uint64 =3D UInt(64, json_gen_fn =3D "libxl__uint64_gen_json", jsonc_json_g= en_fn =3D "libxl__uint64_gen_jso") =20 string =3D Builtin("char *", namespace =3D None, copy_fn =3D "libxl_string= _copy", dispose_fn =3D "free", json_gen_fn =3D "libxl__string_gen_json", + jsonc_json_gen_fn =3D "libxl__string_gen_jso", json_parse_type =3D "JSON_STRING | JSON_NULL", json_parse_fn =3D "libxl__string_parse_json", autogenerate_json =3D False, diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index f738e17b19..8420b2465f 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -545,6 +545,124 @@ static const char *policy_names[4] =3D { "eax", "ebx"= , "ecx", "edx" }; * } */ =20 +#ifdef HAVE_LIBJSONC +int libxl_cpuid_policy_list_gen_jso(json_object **jso_r, libxl_cpuid_polic= y_list *pl) +{ + libxl_cpuid_policy_list policy =3D *pl; + struct xc_xend_cpuid *cpuid; + const struct xc_msr *msr; + json_object *jso_outer; + json_object *jso_array; + int i, j; + int r; + int rc =3D ERROR_FAIL; + + jso_outer =3D json_object_new_object(); + if (!jso_outer) goto out; + + jso_array =3D json_object_new_array(); + if (!jso_array) goto out; + + r =3D json_object_object_add(jso_outer, "cpuid", jso_array); + if (r < 0) { + json_object_put(jso_array); + goto out; + } + + if (policy =3D=3D NULL || policy->cpuid =3D=3D NULL) goto empty; + cpuid =3D policy->cpuid; + + for (i =3D 0; cpuid[i].input[0] !=3D XEN_CPUID_INPUT_UNUSED; i++) { + json_object *jso_inner; + jso_inner =3D json_object_new_object(); + if (!jso_inner) goto out; + + r =3D json_object_array_add(jso_array, jso_inner); + if (r < 0) { + json_object_put(jso_inner); + goto out; + } + + for (j =3D 0; j < 2; j++) { + if (cpuid[i].input[j] !=3D XEN_CPUID_INPUT_UNUSED) { + json_object *jso_value =3D json_object_new_int(cpuid[i].in= put[j]); + if (!jso_value) goto out; + r =3D json_object_object_add(jso_inner, input_names[j], js= o_value); + if (r < 0) { + json_object_put(jso_value); + goto out; + } + } + } + + for (j =3D 0; j < 4; j++) { + if (cpuid[i].policy[j] !=3D NULL) { + json_object *jso_value =3D json_object_new_string_len(cpui= d[i].policy[j], 32); + if (!jso_value) goto out; + r =3D json_object_object_add(jso_inner, policy_names[j], j= so_value); + if (r < 0) { + json_object_put(jso_value); + goto out; + } + } + } + } + +empty: + + jso_array =3D json_object_new_array(); + if (!jso_array) goto out; + + r =3D json_object_object_add(jso_outer, "msr", jso_array); + if (r < 0) { + json_object_put(jso_array); + goto out; + } + + if (!policy || !policy->msr) goto done; + msr =3D policy->msr; + + for (i =3D 0; msr[i].index !=3D XC_MSR_INPUT_UNUSED; i++) { + json_object *jso_inner; + json_object *jso_value; + + jso_inner =3D json_object_new_object(); + if (!jso_inner) goto out; + + r =3D json_object_array_add(jso_array, jso_inner); + if (r < 0) { + json_object_put(jso_inner); + goto out; + } + + jso_value =3D json_object_new_int(msr[i].index); + if (!jso_value) goto out; + r =3D json_object_object_add(jso_inner, "index", jso_value); + if (r < 0) { + json_object_put(jso_value); + goto out; + } + + jso_value =3D json_object_new_string_len(msr[i].policy, 64); + if (!jso_value) goto out; + r =3D json_object_object_add(jso_inner, "policy", jso_value); + if (r < 0) { + json_object_put(jso_value); + goto out; + } + } + +done: + *jso_r =3D jso_outer; + jso_outer =3D NULL; + rc =3D 0; +out: + json_object_put(jso_outer); + return rc; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand, libxl_cpuid_policy_list *pl) { @@ -630,6 +748,7 @@ yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_g= en hand, out: return s; } +#endif =20 int libxl__cpuid_policy_list_parse_json(libxl__gc *gc, const libxl__json_object *o, diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index b66aaa779d..0f707e4204 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -1993,9 +1993,11 @@ _hidden char *libxl__cpupoolid_to_name(libxl__gc *gc= , uint32_t poolid); _hidden int libxl__enum_from_string(const libxl_enum_string_table *t, const char *s, int *e) NN(2); =20 -_hidden yajl_gen_status libxl__string_gen_json(yajl_gen hand, const char *= p); - +#ifdef HAVE_LIBJSONC +typedef int (*libxl__gen_json_callback)(json_object **jso_r, void *); +#elif defined(HAVE_LIBYAJL) typedef yajl_gen_status (*libxl__gen_json_callback)(yajl_gen hand, void *); +#endif _hidden char *libxl__object_to_json(libxl_ctx *ctx, const char *type, libxl__gen_json_callback gen, void *p); =20 @@ -2084,11 +2086,21 @@ int libxl__recvmsg_fds(libxl__gc *gc, int carrier, void *databuf, size_t datalen, int nfds, int fds[], const char *what); =20 +#ifdef HAVE_LIBJSONC +_hidden int libxl__enum_gen_jso(json_object **jso_r, const char *str); +_hidden int libxl__int_gen_jso(json_object **jso_r, int i); +_hidden int libxl__boolean_gen_jso(json_object **jso_r, bool b); +_hidden int libxl__string_gen_jso(json_object **jso_r, const char *p); +#endif + +#ifdef HAVE_LIBYAJL /* from libxl_json */ #include =20 _hidden yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, const char *= str); _hidden yajl_gen_status libxl__yajl_gen_enum(yajl_gen hand, const char *st= r); +_hidden yajl_gen_status libxl__string_gen_json(yajl_gen hand, const char *= p); +#endif =20 typedef enum { JSON_NULL =3D (1 << 0), diff --git a/tools/libs/light/libxl_json.c b/tools/libs/light/libxl_json.c index b26ac901d6..01944ef94d 100644 --- a/tools/libs/light/libxl_json.c +++ b/tools/libs/light/libxl_json.c @@ -19,12 +19,16 @@ #ifdef HAVE_LIBJSONC #include #define USE_LIBJSONC_PARSER +#define USE_LIBJSONC_GEN #endif =20 #ifdef HAVE_LIBYAJL # ifndef USE_LIBJSONC_PARSER # define USE_LIBYAJL_PARSER # endif +# ifndef USE_LIBJSONC_GEN +# define USE_LIBYAJL_GEN +# endif #endif =20 =20 @@ -35,7 +39,9 @@ #ifdef USE_LIBYAJL_PARSER #include #endif +#ifdef USE_LIBYAJL_GEN #include +#endif =20 #include "libxl_internal.h" =20 @@ -103,6 +109,21 @@ yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, = const char *str) return yajl_gen_string(hand, (const unsigned char *)str, strlen(str)); } =20 +#ifdef HAVE_LIBJSONC +int libxl__enum_gen_jso(json_object **jso_r, const char *str) +{ + if (str) { + *jso_r =3D json_object_new_string(str); + if (!*jso_r) + return ERROR_FAIL; + } else { + *jso_r =3D json_object_new_null(); + } + return 0; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl__yajl_gen_enum(yajl_gen hand, const char *str) { if (str) @@ -110,15 +131,28 @@ yajl_gen_status libxl__yajl_gen_enum(yajl_gen hand, c= onst char *str) else return yajl_gen_null(hand); } +#endif =20 /* * YAJL generators for builtin libxl types. */ +#ifdef HAVE_LIBJSONC +int libxl_defbool_gen_jso(json_object **jso_r, libxl_defbool *db) +{ + *jso_r =3D json_object_new_string(libxl_defbool_to_string(*db)); + if (!*jso_r) + return ERROR_FAIL; + return 0; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_defbool_gen_json(yajl_gen hand, libxl_defbool *db) { return libxl__yajl_gen_asciiz(hand, libxl_defbool_to_string(*db)); } +#endif =20 int libxl__defbool_parse_json(libxl__gc *gc, const libxl__json_object *o, libxl_defbool *p) @@ -145,6 +179,16 @@ int libxl__defbool_parse_json(libxl__gc *gc, const lib= xl__json_object *o, return 0; } =20 +#ifdef HAVE_LIBJSONC +int libxl__boolean_gen_jso(json_object **jso_r, bool b) +{ + *jso_r =3D json_object_new_boolean(b); + if (!*jso_r) + return ERROR_FAIL; + return 0; +} +#endif + int libxl__bool_parse_json(libxl__gc *gc, const libxl__json_object *o, bool *p) { @@ -156,6 +200,19 @@ int libxl__bool_parse_json(libxl__gc *gc, const libxl_= _json_object *o, return 0; } =20 +#ifdef HAVE_LIBJSONC +int libxl_uuid_gen_jso(json_object **jso_r, libxl_uuid *uuid) +{ + char buf[LIBXL_UUID_FMTLEN+1]; + snprintf(buf, sizeof(buf), LIBXL_UUID_FMT, LIBXL_UUID_BYTES((*uuid))); + *jso_r =3D json_object_new_string_len(buf, LIBXL_UUID_FMTLEN); + if (!*jso_r) + return ERROR_FAIL; + return 0; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_uuid_gen_json(yajl_gen hand, libxl_uuid *uuid) { @@ -163,6 +220,7 @@ yajl_gen_status libxl_uuid_gen_json(yajl_gen hand, snprintf(buf, sizeof(buf), LIBXL_UUID_FMT, LIBXL_UUID_BYTES((*uuid))); return yajl_gen_string(hand, (const unsigned char *)buf, LIBXL_UUID_FM= TLEN); } +#endif =20 int libxl__uuid_parse_json(libxl__gc *gc, const libxl__json_object *o, libxl_uuid *p) @@ -173,6 +231,39 @@ int libxl__uuid_parse_json(libxl__gc *gc, const libxl_= _json_object *o, return libxl_uuid_from_string(p, o->u.string); } =20 +#ifdef HAVE_LIBJSONC +int libxl_bitmap_gen_jso(json_object **jso_r, libxl_bitmap *bitmap) +{ + json_object *jso; + int i; + int r; + int rc =3D ERROR_FAIL; + + jso =3D json_object_new_array(); + if (!jso) goto out; + + libxl_for_each_bit(i, *bitmap) { + if (libxl_bitmap_test(bitmap, i)) { + json_object *jso_value =3D json_object_new_int(i); + if (!jso_value) goto out; + r =3D json_object_array_add(jso, jso_value); + if (r) { + json_object_put(jso_value); + goto out; + } + } + } + + *jso_r =3D jso; + jso =3D NULL; + rc =3D 0; +out: + json_object_put(jso); + return rc; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_bitmap_gen_json(yajl_gen hand, libxl_bitmap *bitmap) { @@ -192,6 +283,7 @@ yajl_gen_status libxl_bitmap_gen_json(yajl_gen hand, out: return s; } +#endif =20 int libxl__bitmap_parse_json(libxl__gc *gc, const libxl__json_object *o, libxl_bitmap *p) @@ -227,6 +319,42 @@ int libxl__bitmap_parse_json(libxl__gc *gc, const libx= l__json_object *o, return 0; } =20 +#ifdef HAVE_LIBJSONC +int libxl_key_value_list_gen_jso(json_object **jso_r, libxl_key_value_list= *pkvl) +{ + libxl_key_value_list kvl =3D *pkvl; + json_object *jso; + int i; + + jso =3D json_object_new_object(); + if (!jso) goto out; + + if (!kvl) goto empty; + + for (i =3D 0; kvl[i] !=3D NULL; i +=3D 2) { + json_object *jso_value; + if (kvl[i + 1]) { + jso_value =3D json_object_new_string(kvl[i+1]); + if (!jso_value) goto out; + } else { + jso_value =3D json_object_new_null(); + } + int r =3D json_object_object_add(jso, kvl[i], jso_value); + if (r) { + json_object_put(jso_value); + goto out; + } + } +empty: + *jso_r =3D jso; + return 0; +out: + json_object_put(jso); + return ERROR_FAIL; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_key_value_list_gen_json(yajl_gen hand, libxl_key_value_list *pkvl) { @@ -253,6 +381,7 @@ yajl_gen_status libxl_key_value_list_gen_json(yajl_gen = hand, out: return s; } +#endif =20 int libxl__key_value_list_parse_json(libxl__gc *gc, const libxl__json_obje= ct *o, libxl_key_value_list *p) @@ -289,6 +418,39 @@ int libxl__key_value_list_parse_json(libxl__gc *gc, co= nst libxl__json_object *o, return 0; } =20 +#ifdef HAVE_LIBJSONC +int libxl_string_list_gen_jso(json_object **jso_r, libxl_string_list *pl) +{ + libxl_string_list l =3D *pl; + json_object *jso; + int i; + int rc =3D ERROR_FAIL; + + jso =3D json_object_new_array(); + if (!jso) goto out; + + if (!l) goto empty; + + for (i =3D 0; l[i] !=3D NULL; i++) { + json_object *jso_value =3D json_object_new_string(l[i]); + if (!jso_value) goto out; + int r =3D json_object_array_add(jso, jso_value); + if (r) { + json_object_put(jso_value); + goto out; + } + } +empty: + *jso_r =3D jso; + jso =3D NULL; + rc =3D 0; +out: + json_object_put(jso); + return rc; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_string_list_gen_json(yajl_gen hand, libxl_string_lis= t *pl) { libxl_string_list l =3D *pl; @@ -309,6 +471,7 @@ yajl_gen_status libxl_string_list_gen_json(yajl_gen han= d, libxl_string_list *pl) out: return s; } +#endif =20 int libxl__string_list_parse_json(libxl__gc *gc, const libxl__json_object = *o, libxl_string_list *p) @@ -342,12 +505,26 @@ int libxl__string_list_parse_json(libxl__gc *gc, cons= t libxl__json_object *o, return 0; } =20 +#ifdef HAVE_LIBJSONC +int libxl_mac_gen_jso(json_object **jso_r, libxl_mac *mac) +{ + char buf[LIBXL_MAC_FMTLEN+1]; + snprintf(buf, sizeof(buf), LIBXL_MAC_FMT, LIBXL_MAC_BYTES((*mac))); + *jso_r =3D json_object_new_string_len(buf, LIBXL_MAC_FMTLEN); + if (!*jso_r) + return ERROR_FAIL; + return 0; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_mac_gen_json(yajl_gen hand, libxl_mac *mac) { char buf[LIBXL_MAC_FMTLEN+1]; snprintf(buf, sizeof(buf), LIBXL_MAC_FMT, LIBXL_MAC_BYTES((*mac))); return yajl_gen_string(hand, (const unsigned char *)buf, LIBXL_MAC_FMT= LEN); } +#endif =20 int libxl__mac_parse_json(libxl__gc *gc, const libxl__json_object *o, libxl_mac *p) @@ -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); } =20 +#ifdef HAVE_LIBJSONC +int libxl_hwcap_gen_jso(json_object **jso_r, libxl_hwcap *p) +{ + json_object *jso; + int i; + int rc =3D ERROR_FAIL; + + jso =3D json_object_new_array(); + if (!jso) goto out; + + for(i=3D0; i<4; i++) { + json_object *jso_value =3D json_object_new_int((*p)[i]); + if (!jso_value) + goto out; + int r =3D json_object_array_add(jso, jso_value); + if (r) { + json_object_put(jso_value); + goto out; + } + } + *jso_r =3D jso; + jso =3D NULL; + rc =3D 0; +out: + json_object_put(jso); + return rc; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_hwcap_gen_json(yajl_gen hand, libxl_hwcap *p) { @@ -375,6 +582,7 @@ yajl_gen_status libxl_hwcap_gen_json(yajl_gen hand, out: return s; } +#endif =20 int libxl__hwcap_parse_json(libxl__gc *gc, const libxl__json_object *o, libxl_hwcap *p) @@ -397,6 +605,37 @@ int libxl__hwcap_parse_json(libxl__gc *gc, const libxl= __json_object *o, return 0; } =20 +#ifdef HAVE_LIBJSONC +int libxl_ms_vm_genid_gen_jso(json_object **jso_r, libxl_ms_vm_genid *p) +{ + json_object *jso; + int i; + int rc =3D ERROR_FAIL; + + jso =3D json_object_new_array_ext(LIBXL_MS_VM_GENID_LEN); + if (!jso) goto out; + + for (i =3D 0; i < LIBXL_MS_VM_GENID_LEN; i++) { + json_object *jso_value =3D json_object_new_int(p->bytes[i]); + if (!jso_value) + goto out; + int r =3D json_object_array_add(jso, jso_value); + if (r) { + json_object_put(jso_value); + goto out; + } + } + + *jso_r =3D jso; + jso =3D NULL; + rc =3D 0; +out: + json_object_put(jso); + return rc; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen hand, libxl_ms_vm_geni= d *p) { yajl_gen_status s; @@ -414,6 +653,7 @@ yajl_gen_status libxl_ms_vm_genid_gen_json(yajl_gen han= d, libxl_ms_vm_genid *p) =20 return yajl_gen_array_close(hand); } +#endif =20 int libxl__ms_vm_genid_parse_json(libxl__gc *gc, const libxl__json_object = *o, libxl_ms_vm_genid *p) @@ -436,6 +676,21 @@ int libxl__ms_vm_genid_parse_json(libxl__gc *gc, const= libxl__json_object *o, return 0; } =20 +#ifdef HAVE_LIBJSONC +int libxl__string_gen_jso(json_object **jso_r, const char *p) +{ + if (p) { + *jso_r =3D json_object_new_string(p); + if (!*jso_r) + return ERROR_FAIL; + } else { + *jso_r =3D json_object_new_null(); + } + return 0; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl__string_gen_json(yajl_gen hand, const char *p) { @@ -444,6 +699,7 @@ yajl_gen_status libxl__string_gen_json(yajl_gen hand, else return yajl_gen_null(hand); } +#endif =20 int libxl__string_parse_json(libxl__gc *gc, const libxl__json_object *o, char **p) @@ -1161,6 +1417,7 @@ libxl__json_object *libxl__json_parse(libxl__gc *gc, = const char *s) return NULL; } =20 +#ifdef USE_LIBYAJL_GEN static const char *yajl_gen_status_to_string(yajl_gen_status s) { switch (s) { @@ -1185,7 +1442,43 @@ static const char *yajl_gen_status_to_string(yajl_ge= n_status s) return "unknown error"; } } +#endif =20 +#ifdef USE_LIBJSONC_GEN +char *libxl__object_to_json(libxl_ctx *ctx, const char *type, + libxl__gen_json_callback gen, void *p) +{ + const char *buf; + char *ret =3D NULL; + json_object *jso =3D NULL; + int rc; + + rc =3D gen(&jso, p); + if (rc) + goto out; + + buf =3D json_object_to_json_string_ext(jso, JSON_C_TO_STRING_PRETTY); + if (!buf) + goto out; + ret =3D strdup((const char *)buf); + +out: + json_object_put(jso); + + if (rc) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "unable to convert %s to JSON representation. ", + type); + } else if (!ret) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "unable to allocate space for to JSON representation of= %s", + type); + } + + return ret; +} + +#elif defined(USE_LIBYAJL_GEN) char *libxl__object_to_json(libxl_ctx *ctx, const char *type, libxl__gen_json_callback gen, void *p) { @@ -1224,6 +1517,7 @@ char *libxl__object_to_json(libxl_ctx *ctx, const cha= r *type, =20 return ret; } +#endif =20 char *libxl__json_object_to_json(libxl__gc *gc, const libxl__json_object *args) @@ -1257,6 +1551,17 @@ char *libxl__json_object_to_json(libxl__gc *gc, return ret; } =20 +#ifdef HAVE_LIBJSONC +int libxl__uint64_gen_jso(json_object **jso_r, uint64_t val) +{ + *jso_r =3D json_object_new_uint64(val); + if (!*jso_r) + return ERROR_FAIL; + return 0; +} +#endif + +#ifdef HAVE_LIBYAJL yajl_gen_status libxl__uint64_gen_json(yajl_gen hand, uint64_t val) { char *num; @@ -1277,6 +1582,7 @@ yajl_gen_status libxl__uint64_gen_json(yajl_gen hand,= uint64_t val) out: return s; } +#endif =20 int libxl__object_from_json(libxl_ctx *ctx, const char *type, libxl__json_parse_callback parse, @@ -1308,6 +1614,16 @@ int libxl__object_from_json(libxl_ctx *ctx, const ch= ar *type, return rc; } =20 +#ifdef HAVE_LIBJSONC +int libxl__int_gen_jso(json_object **jso_r, int i) +{ + *jso_r =3D json_object_new_int(i); + if (!*jso_r) + return ERROR_FAIL; + return 0; +} +#endif + int libxl__int_parse_json(libxl__gc *gc, const libxl__json_object *o, void *p) { diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index a6030a2dbd..caeddbcdc0 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -7,9 +7,9 @@ namespace("libxl_") =20 libxl_defbool =3D Builtin("defbool", json_parse_type=3D"JSON_STRING", pass= by=3DPASS_BY_REFERENCE, copy_fn=3DNone, check_default_fn=3D"libxl__defbool_is_default") -libxl_domid =3D Builtin("domid", json_gen_fn =3D "yajl_gen_integer", json_= parse_fn =3D "libxl__uint32_parse_json", +libxl_domid =3D Builtin("domid", json_gen_fn =3D "yajl_gen_integer", jsonc= _json_gen_fn =3D "libxl__uint64_gen_jso", json_parse_fn =3D "libxl__uint32_= parse_json", json_parse_type =3D "JSON_INTEGER", autogenerate_jso= n =3D False, copy_fn=3DNone) -libxl_devid =3D Builtin("devid", json_gen_fn =3D "yajl_gen_integer", json_= parse_fn =3D "libxl__int_parse_json", +libxl_devid =3D Builtin("devid", json_gen_fn =3D "yajl_gen_integer", jsonc= _json_gen_fn =3D "libxl__int_gen_jso", json_parse_fn =3D "libxl__int_parse_= json", json_parse_type =3D "JSON_INTEGER", autogenerate_jso= n =3D False, signed =3D True, init_val=3D"-1", copy_fn=3DNone) libxl_uuid =3D Builtin("uuid", json_parse_type=3D"JSON_STRING", passby=3DP= ASS_BY_REFERENCE, check_default_fn=3D"libxl_uuid_is_nil", @@ -37,7 +37,8 @@ libxl_ms_vm_genid =3D Builtin("ms_vm_genid", passby=3DPAS= S_BY_REFERENCE, check_defau # Specific integer types # =20 -MemKB =3D UInt(64, init_val =3D "LIBXL_MEMKB_DEFAULT", json_gen_fn =3D "li= bxl__uint64_gen_json") +MemKB =3D UInt(64, init_val =3D "LIBXL_MEMKB_DEFAULT", + json_gen_fn =3D "libxl__uint64_gen_json", jsonc_json_gen_fn = =3D "libxl__uint64_gen_jso") =20 # # Constants / Enumerations diff --git a/tools/libs/light/libxl_types_internal.idl b/tools/libs/light/l= ibxl_types_internal.idl index 0425e9b6b0..ab4ee92870 100644 --- a/tools/libs/light/libxl_types_internal.idl +++ b/tools/libs/light/libxl_types_internal.idl @@ -1,7 +1,8 @@ namespace("libxl__") hidden(True) =20 -libxl_domid =3D Builtin("domid", namespace=3D"libxl_", json_gen_fn =3D "ya= jl_gen_integer", +libxl_domid =3D Builtin("domid", namespace=3D"libxl_", + json_gen_fn =3D "yajl_gen_integer", jsonc_json_gen_f= n =3D "libxl__uint64_gen_jso", json_parse_fn =3D "libxl__uint32_parse_json", json_parse_type =3D = "JSON_INTEGER", autogenerate_json =3D False, copy_fn =3D None) =20 diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index 3fbc0698b7..18cfd3c217 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -60,6 +60,48 @@ static int maybe_printf(const char *fmt, ...) return count; } =20 + +#ifdef HAVE_LIBJSONC +static int printf_info_one_json(json_object **jso_r, int domid, + libxl_domain_config *d_config) +{ + json_object *jso =3D NULL; + json_object *jso_config =3D NULL; + enum json_tokener_error error; + char *s =3D NULL; + int r =3D EXIT_FAILURE; + + s =3D libxl_domain_config_to_json(ctx, d_config); + jso_config =3D json_tokener_parse_verbose(s, &error); + if (!jso_config) { + fprintf(stderr, "fail to parse JSON from libxl_domain_config_to_js= on(): %s\n", + json_tokener_error_desc(error)); + goto out; + } + + jso =3D json_object_new_object(); + if (domid !=3D -1) + json_object_object_add(jso, "domid", json_object_new_int(domid)); + else + json_object_object_add(jso, "domid", json_object_new_null()); + + + json_object_object_add(jso, "config", jso_config); + jso_config =3D NULL; + + *jso_r =3D jso; + jso =3D NULL; + r =3D EXIT_SUCCESS; + +out: + free(s); + json_object_put(jso); + json_object_put(jso_config); + return r; +} + +#elif defined(HAVE_LIBYAJL) + static yajl_gen_status printf_info_one_json(yajl_gen hand, int domid, libxl_domain_config *d_config) { @@ -95,6 +137,7 @@ static yajl_gen_status printf_info_one_json(yajl_gen han= d, int domid, out: return s; } +#endif =20 void printf_info(enum output_format output_format, int domid, @@ -103,6 +146,27 @@ void printf_info(enum output_format output_format, if (output_format =3D=3D OUTPUT_FORMAT_SXP) return printf_info_sexp(domid, d_config, fh); =20 +#ifdef HAVE_LIBJSONC + int r; + const char *buf; + json_object *jso; + + r =3D printf_info_one_json(&jso, domid, d_config); + if (r) + goto out; + + buf =3D json_object_to_json_string_ext(jso, JSON_C_TO_STRING_PRETTY); + if (!buf) + goto out; + + fputs(buf, fh); + +out: + json_object_put(jso); + flush_stream(fh); + return; + +#elif defined(HAVE_LIBYAJL) const char *buf; libxl_yajl_length len =3D 0; yajl_gen_status s; @@ -132,6 +196,7 @@ void printf_info(enum output_format output_format, "unable to format domain config as JSON (YAJL:%d)\n", s); =20 flush_stream(fh); +#endif } =20 static void output_xeninfo(void) @@ -475,11 +540,20 @@ static void list_domains_details(const libxl_dominfo = *info, int nb_domain) =20 int i, rc; =20 + const char *buf; +#ifdef HAVE_LIBJSONC + json_object *jso =3D NULL; +#elif defined(HAVE_LIBYAJL) yajl_gen hand =3D NULL; yajl_gen_status s; - const char *buf; libxl_yajl_length yajl_len =3D 0; +#endif =20 +#ifdef HAVE_LIBJSONC + if (default_output_format =3D=3D OUTPUT_FORMAT_JSON) { + jso =3D json_object_new_array(); + } +#elif defined(HAVE_LIBYAJL) if (default_output_format =3D=3D OUTPUT_FORMAT_JSON) { hand =3D libxl_yajl_gen_alloc(NULL); if (!hand) { @@ -492,6 +566,7 @@ static void list_domains_details(const libxl_dominfo *i= nfo, int nb_domain) goto out; } else s =3D yajl_gen_status_ok; +#endif =20 for (i =3D 0; i < nb_domain; i++) { libxl_domain_config_init(&d_config); @@ -499,16 +574,32 @@ static void list_domains_details(const libxl_dominfo = *info, int nb_domain) &d_config, NULL); if (rc) continue; - if (default_output_format =3D=3D OUTPUT_FORMAT_JSON) + if (default_output_format =3D=3D OUTPUT_FORMAT_JSON) { +#ifdef HAVE_LIBJSONC + json_object *jso_value; + rc =3D printf_info_one_json(&jso_value, info[i].domid, &d_conf= ig); + json_object_array_add(jso, jso_value); +#elif defined(HAVE_LIBYAJL) s =3D printf_info_one_json(hand, info[i].domid, &d_config); - else +#endif + } else printf_info_sexp(info[i].domid, &d_config, stdout); libxl_domain_config_dispose(&d_config); +#ifdef HAVE_LIBJSONC + if (rc) + goto out; +#elif defined(HAVE_LIBYAJL) if (s !=3D yajl_gen_status_ok) goto out; +#endif } =20 if (default_output_format =3D=3D OUTPUT_FORMAT_JSON) { +#ifdef HAVE_LIBJSONC + buf =3D json_object_to_json_string_ext(jso, JSON_C_TO_STRING_PRETT= Y); + if (!buf) + goto out; +#elif defined(HAVE_LIBYAJL) s =3D yajl_gen_array_close(hand); if (s !=3D yajl_gen_status_ok) goto out; @@ -516,16 +607,21 @@ static void list_domains_details(const libxl_dominfo = *info, int nb_domain) s =3D yajl_gen_get_buf(hand, (const unsigned char **)&buf, &yajl_l= en); if (s !=3D yajl_gen_status_ok) goto out; +#endif =20 puts(buf); } =20 out: if (default_output_format =3D=3D OUTPUT_FORMAT_JSON) { +#ifdef HAVE_LIBJSONC + json_object_put(jso); +#elif defined(HAVE_LIBYAJL) yajl_gen_free(hand); if (s !=3D yajl_gen_status_ok) fprintf(stderr, "unable to format domain config as JSON (YAJL:%d)\n", = s); +#endif } } =20 --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664999; cv=none; d=zohomail.com; s=zohoarc; b=HhSScZ1biOu3354BqLd1E8cEzyBBxp/8p6cA4a4yfKFPitXQYKgDuFUN9PrivfC+/cqO/YZTGtlS8yFI0SNnIADK6/yDOTdmgvnbNu4Ng4hBzcKpRlfFevyEaW57lp7fJLDArp+dJeqrI3sH119aY48MfXnJd1gFTSjH38vQ42I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664999; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ifWlGzTUU1FY9skxB0Gurmq9TF1yYQXRL2ntyqKDdmw=; b=KU6F+W+aSbljO69Z0GlyqjFUaQ5V3/jg9qh8as9acIqSOlZVpTUDu/v3y36tyMfz2qJ3I2WwuS8Jy1VNjmvO34S4nFL3HLn62UXeCIPwRsFCL7L7zBzUUXDC2iS1CCE18BMBnI1z5welSE/i9LYgEUV4bfvoONiwemwNQ1mlclo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175466499922587.33876405979947; Fri, 8 Aug 2025 07:56:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074670.1437220 (Exim 4.92) (envelope-from ) id 1ukOVy-0001eG-LS; Fri, 08 Aug 2025 14:56:14 +0000 Received: by outflank-mailman (output) from mailman id 1074670.1437220; Fri, 08 Aug 2025 14:56:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVy-0001c8-FX; Fri, 08 Aug 2025 14:56:14 +0000 Received: by outflank-mailman (input) for mailman id 1074670; Fri, 08 Aug 2025 14:56:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVw-0001BL-Oz for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:12 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVw-007zrt-1n; Fri, 08 Aug 2025 14:56:12 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVw-009BYT-0y; Fri, 08 Aug 2025 14:56:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ifWlGzTUU1FY9skxB0Gurmq9TF1yYQXRL2ntyqKDdmw=; b=u2zzoRO9ZvKkaKuhjxRpPiqHHX sU0CZMwSW8rP2QH7c/CKzAXK1kBOJMeIxKR/qKgpk5JpXkTffqdbWwG8BMoHFFN05NjhDEebiFauy nNZTRzGMToOHOgHPMVImCHOo46WEujyVqbjI5pDAT3NJs+dfmRSKqk/pziB53sSh1H+4=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Juergen Gross Subject: [XEN PATCH 08/11] libxl: convert libxl__json_object_to_json() to json_object Date: Fri, 8 Aug 2025 16:55:59 +0200 Message-Id: <20250808145602.41716-9-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754665001414124100 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD But keep the implementation done for YAJL. Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/light/libxl_json.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/libs/light/libxl_json.c b/tools/libs/light/libxl_json.c index 01944ef94d..cffda158d2 100644 --- a/tools/libs/light/libxl_json.c +++ b/tools/libs/light/libxl_json.c @@ -104,10 +104,12 @@ typedef struct libxl__yajl_ctx { * YAJL Helper */ =20 +#ifdef HAVE_LIBYAJL yajl_gen_status libxl__yajl_gen_asciiz(yajl_gen hand, const char *str) { return yajl_gen_string(hand, (const unsigned char *)str, strlen(str)); } +#endif =20 #ifdef HAVE_LIBJSONC int libxl__enum_gen_jso(json_object **jso_r, const char *str) @@ -1522,6 +1524,29 @@ char *libxl__object_to_json(libxl_ctx *ctx, const ch= ar *type, char *libxl__json_object_to_json(libxl__gc *gc, const libxl__json_object *args) { +#ifdef HAVE_LIBJSONC + const char *buf; + json_object *root; + char *ret =3D NULL; + int rc; + + if (!args) + return NULL; + + rc =3D libxl__json_object_to_json_object(gc, &root, args); + if (rc) + goto out; + + buf =3D json_object_to_json_string_ext(root, JSON_C_TO_STRING_PRETTY); + if (!buf) + goto out; + + ret =3D libxl__strdup(gc, buf); + +out: + json_object_put(root); + return ret; +#elif defined(HAVE_LIBYAJL) const unsigned char *buf; libxl_yajl_length len; yajl_gen_status s; @@ -1549,6 +1574,7 @@ char *libxl__json_object_to_json(libxl__gc *gc, out: yajl_gen_free(hand); return ret; +#endif } =20 #ifdef HAVE_LIBJSONC --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754664991; cv=none; d=zohomail.com; s=zohoarc; b=Od7GurmB2krajIV/Ieokw9eCdqUXT0HKz+xo9NQ6+NPNcOVPNzKVZ9i5ITYwt4YVDIJlqYju/KVE/Q6a2ltcsuF5acgVByi6jgdgauZIFjYPNeEzGgvFYzJiz1G+Ndf6hDKcVqYuovEoUpKHjqGarh8mX4me3qyOTp1eusfkXCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754664991; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=f3B1XR/rJqzESb9x9Ihv7VOZk7psRW9ng9FNM3jhUwY=; b=CpMI/UpOiZntYFxCoKc66R6W4SfhJJQ8kjAcE99HSuRLtTOccgSwq7JwYRv7pADrArUqygKmo2YEyjjViM6dc6XTJnZkqLaWbaY28iApuWga5G7vYCb5QODS2T8J8Hu86dEnifpt+PLCdD4hZb+5+ScUtVmsljhtvlQKWfv26ro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754664991346130.37672391490253; Fri, 8 Aug 2025 07:56:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074671.1437225 (Exim 4.92) (envelope-from ) id 1ukOVz-0001jP-39; Fri, 08 Aug 2025 14:56:15 +0000 Received: by outflank-mailman (output) from mailman id 1074671.1437225; Fri, 08 Aug 2025 14:56:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVy-0001ht-Sf; Fri, 08 Aug 2025 14:56:14 +0000 Received: by outflank-mailman (input) for mailman id 1074671; Fri, 08 Aug 2025 14:56:13 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOVx-0001QK-J2 for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 14:56:13 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOVx-007zrz-1I; Fri, 08 Aug 2025 14:56:13 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVx-009BYT-0R; Fri, 08 Aug 2025 14:56:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=f3B1XR/rJqzESb9x9Ihv7VOZk7psRW9ng9FNM3jhUwY=; b=BGYlQfWXBzDQz4BrtRW8Dn5nPG 2R5//+BgDe8stX3MZHkI252eE/IYblCZ82+rLY4026MIwGysx1pi/9GwXBVduF+sTJsZR8qcqVgZf +pAWRePIk6SKUGCSqn2zFEPuC7rsnVY/+adAIRfFi7oquHuSY7cgrWsM/lVlgu+Aun2c=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Juergen Gross Subject: [XEN PATCH 09/11] tools/libxenstat: Use json-c when available Date: Fri, 8 Aug 2025 16:56:00 +0200 Message-Id: <20250808145602.41716-10-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754664993403124100 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD This is mainly a copy of the existing code in yajl and use json-c instead. Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/stat/Makefile | 3 +- tools/libs/stat/xenstat_qmp.c | 126 ++++++++++++++++++++++++++++++++-- 2 files changed, 121 insertions(+), 8 deletions(-) diff --git a/tools/libs/stat/Makefile b/tools/libs/stat/Makefile index a968eaff48..3f13cf07be 100644 --- a/tools/libs/stat/Makefile +++ b/tools/libs/stat/Makefile @@ -24,7 +24,8 @@ OBJS-$(CONFIG_SunOS) +=3D xenstat_solaris.o OBJS-$(CONFIG_NetBSD) +=3D xenstat_netbsd.o OBJS-$(CONFIG_FreeBSD) +=3D xenstat_freebsd.o =20 -LDLIBS-y +=3D -lyajl +LDLIBS-y +=3D $(YAJL_LIBS) +LDLIBS-y +=3D $(LIBJSONC_LIBS) LDLIBS-$(CONFIG_SunOS) +=3D -lkstat LDLIBS +=3D $(LDLIBS-y) =20 diff --git a/tools/libs/stat/xenstat_qmp.c b/tools/libs/stat/xenstat_qmp.c index 9909b9727e..21e321fffa 100644 --- a/tools/libs/stat/xenstat_qmp.c +++ b/tools/libs/stat/xenstat_qmp.c @@ -24,6 +24,10 @@ =20 #include "xenstat_priv.h" =20 +#ifdef HAVE_LIBJSONC +#include + +#elif defined(HAVE_LIBYAJL) #ifdef HAVE_YAJL_YAJL_VERSION_H # include #endif @@ -32,11 +36,13 @@ #if defined(YAJL_MAJOR) && (YAJL_MAJOR > 1) # define HAVE_YAJL_V2 1 #endif +#endif =20 #ifdef HAVE_YAJL_V2 - #include +#endif =20 +#if defined(HAVE_LIBJSONC) || defined(HAVE_YAJL_V2) static unsigned char *qmp_query(int, const char *); =20 enum query_blockstats { @@ -76,9 +82,10 @@ enum query_block { "type": 'str' }]} */ -static char *qmp_get_block_image(xenstat_node *node, char *qmp_devname, in= t qfd) +static char *qmp_get_block_image(xenstat_node *node, const char *qmp_devna= me, int qfd) { - char *tmp, *file =3D NULL; + const char *tmp; + char *file =3D NULL; const char *query_block_cmd =3D "{ \"execute\": \"query-block\" }"; static const char *const qblock[] =3D { [ QMP_BLOCK_RETURN ] =3D "return", @@ -88,13 +95,56 @@ static char *qmp_get_block_image(xenstat_node *node, ch= ar *qmp_devname, int qfd) }; const char *ptr[] =3D {0, 0}; unsigned char *qmp_stats; - yajl_val info, ret_obj, dev_obj, n; int i; =20 if ((qmp_stats =3D qmp_query(qfd, query_block_cmd)) =3D=3D NULL) return NULL; =20 +#ifdef HAVE_LIBJSONC + json_object *jso; + enum json_tokener_error error; + jso =3D json_tokener_parse_verbose((const char *)qmp_stats, &error); + free(qmp_stats); + if (jso =3D=3D NULL) + return NULL; + + ptr[0] =3D qblock[QMP_BLOCK_RETURN]; /* "return" */ + json_object *ret_jso =3D json_object_object_get(jso, ptr[0]); + if (ret_jso =3D=3D NULL) + goto done; + + for (i=3D0; i (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754665255232491.3440092641915; Fri, 8 Aug 2025 08:00:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074700.1437242 (Exim 4.92) (envelope-from ) id 1ukOaG-00065L-Pd; Fri, 08 Aug 2025 15:00:40 +0000 Received: by outflank-mailman (output) from mailman id 1074700.1437242; Fri, 08 Aug 2025 15:00:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOaG-00065E-N5; Fri, 08 Aug 2025 15:00:40 +0000 Received: by outflank-mailman (input) for mailman id 1074700; Fri, 08 Aug 2025 15:00:40 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOaG-00064e-8n for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 15:00:40 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOaG-00800R-0c; Fri, 08 Aug 2025 15:00:40 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVx-009BYT-2n; Fri, 08 Aug 2025 14:56:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=9LmUJ4zuB4olL3YoOObx5zrJYD33c+ZXbGLTgVb/atI=; b=4l+P6WMM1+cZLcw5pbkvqZMpgi d/gUyDA88izucPA6REXG8q0Zwv4vJmYH1xyHevK2wDhjM+zmqukNG504BRDEuwSspYKR6mBORIGyx KKQKechLTjeE9NnIw5fvpu/NSSgRrQWF4d2cGu8VdYs8x9DCALPV4QV99dgKdQY8x1Ws=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD Subject: [XEN PATCH 10/11] configure: Use json-c by default, fallback to yajl Date: Fri, 8 Aug 2025 16:56:01 +0200 Message-Id: <20250808145602.41716-11-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754665256178116600 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD Signed-off-by: Anthony PERARD --- tools/configure | 97 +++++++++++++++++++++++++++++----------------- tools/configure.ac | 12 +++--- 2 files changed, 69 insertions(+), 40 deletions(-) diff --git a/tools/configure b/tools/configure index edd1701b2d..0eb7a0ab6a 100755 --- a/tools/configure +++ b/tools/configure @@ -9692,41 +9692,7 @@ fi # Put the nasty error message in config.log where it belongs echo "$libjsonc_PKG_ERRORS" >&5 =20 - as_fn_error $? "Package requirements (json-c) were not met: - -$libjsonc_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables libjsonc_CFLAGS -and libjsonc_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed =3D untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. M= ake sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables libjsonc_CFLAGS -and libjsonc_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5; } -else - libjsonc_CFLAGS=3D$pkg_cv_libjsonc_CFLAGS - libjsonc_LIBS=3D$pkg_cv_libjsonc_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - -printf "%s\n" "#define HAVE_LIBJSONC 1" >>confdefs.h - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for yajl_alloc in -= lyajl" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for yajl_alloc in = -lyajl" >&5 printf %s "checking for yajl_alloc in -lyajl... " >&6; } if test ${ac_cv_lib_yajl_yajl_alloc+y} then : @@ -9772,6 +9738,67 @@ else $as_nop as_fn_error $? "Could not find yajl" "$LINENO" 5 fi =20 + +elif test $pkg_failed =3D untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for yajl_alloc in = -lyajl" >&5 +printf %s "checking for yajl_alloc in -lyajl... " >&6; } +if test ${ac_cv_lib_yajl_yajl_alloc+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=3D$LIBS +LIBS=3D"-lyajl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char yajl_alloc (); +int +main (void) +{ +return yajl_alloc (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_yajl_yajl_alloc=3Dyes +else $as_nop + ac_cv_lib_yajl_yajl_alloc=3Dno +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=3D$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_yajl_yajl= _alloc" >&5 +printf "%s\n" "$ac_cv_lib_yajl_yajl_alloc" >&6; } +if test "x$ac_cv_lib_yajl_yajl_alloc" =3D xyes +then : + YAJL_LIBS=3D-lyajl + + +printf "%s\n" "#define HAVE_LIBYAJL 1" >>confdefs.h + +else $as_nop + as_fn_error $? "Could not find yajl" "$LINENO" 5 +fi + + +else + libjsonc_CFLAGS=3D$pkg_cv_libjsonc_CFLAGS + libjsonc_LIBS=3D$pkg_cv_libjsonc_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + +printf "%s\n" "#define HAVE_LIBJSONC 1" >>confdefs.h + +fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for deflateCopy in = -lz" >&5 printf %s "checking for deflateCopy in -lz... " >&6; } if test ${ac_cv_lib_z_deflateCopy+y} diff --git a/tools/configure.ac b/tools/configure.ac index bb40b5b3f0..7267d02a04 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -425,11 +425,13 @@ AC_SUBST([ZLIB_LIBS]) AX_CHECK_EXTFS AX_CHECK_PTHREAD PKG_CHECK_MODULES([libjsonc], [json-c], - [AC_DEFINE([HAVE_LIBJSONC], [1], [Use library json-c])]) -AC_CHECK_LIB([yajl], [yajl_alloc], - [AC_SUBST([YAJL_LIBS],[-lyajl]) - AC_DEFINE([HAVE_LIBYAJL],[1],[Define to 1 if you have the `yajl' libra= ry (-lyajl).])], - [AC_MSG_ERROR([Could not find yajl])]) + [AC_DEFINE([HAVE_LIBJSONC], [1], [Use library json-c])], + [AC_CHECK_LIB([yajl], [yajl_alloc], + [AC_SUBST([YAJL_LIBS],[-lyajl]) + AC_DEFINE([HAVE_LIBYAJL],[1],[Define to 1 if you have the `yajl' = library (-lyajl).])], + [AC_MSG_ERROR([Could not find yajl])]) +]) + AC_CHECK_LIB([z], [deflateCopy], [], [AC_MSG_ERROR([Could not find zlib])]) AC_CHECK_HEADER([argp.h], [ AC_CHECK_LIB([argp], [argp_usage], [argp_ldflags=3D"-largp"]) --=20 Anthony PERARD From nobody Mon Dec 15 22:34:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1754665256; cv=none; d=zohomail.com; s=zohoarc; b=Z135w0YKqf/eT6S4N0W/kqMCsIndILrIBneTS8U82ax7ndpnPnIVmvLZCPqVrJclH9SAShsfKTnmnlLbrWiyObx6TIZOj9Z6tAyyUTY+Jip9wiRRmkBzZIEDZnwnRQ9iayHFua8t+5BJ8pcurgzPQX8h62Z06GsADiZG8wdmV6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754665256; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OI5YJNC114wPAaP6LK8uGuarwiAKbs2E8HSv0E4xKds=; b=l3QbtaenPji6aiDUSEdTfIjsl1Aby+aC6gwaDDd13EqM1gQ2p1gzO1vj4GWrbYZxGSQnFk35q4V2siFU9JqL2cU/VAEoQ/CmD0T8r3jsc1EZHxD8YcB13VrSZzax5A7itE9DR3kmNKDzaWvEGDdXLO1mytavAGH//GD8zciub/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1754665256976605.427302082623; Fri, 8 Aug 2025 08:00:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1074705.1437253 (Exim 4.92) (envelope-from ) id 1ukOaJ-0006L0-0u; Fri, 08 Aug 2025 15:00:43 +0000 Received: by outflank-mailman (output) from mailman id 1074705.1437253; Fri, 08 Aug 2025 15:00:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOaI-0006Kt-Ty; Fri, 08 Aug 2025 15:00:42 +0000 Received: by outflank-mailman (input) for mailman id 1074705; Fri, 08 Aug 2025 15:00:41 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ukOaH-0006Ie-K5 for xen-devel@lists.xenproject.org; Fri, 08 Aug 2025 15:00:41 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1ukOaG-00800T-0j; Fri, 08 Aug 2025 15:00:40 +0000 Received: from [2a01:e0a:1da:8420:b77:bd5:6e45:7633] (helo=l14..) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ukOVz-009BYT-1b; Fri, 08 Aug 2025 14:56:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=OI5YJNC114wPAaP6LK8uGuarwiAKbs2E8HSv0E4xKds=; b=6aVE2vFT0EtHMQZpcEjIyNDb+R O59epHd7LvO0+/TYMmLJVos4FH7fsfVTF2lCmrUI6LiFl/O1qqgMR9llBigfyQnJu6lY60dyvzPMz 1d19COEExUGVbKuYkFGOfoIdYIe8D8SZM/RMksQM2F7k2XGxx/nnZxp9VIbCdKveVLRU=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Oleksii Kurochko , Community Manager , Andrew Cooper , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [XEN PATCH 11/11] Update CHANGELOG and README with dependency on json-c Date: Fri, 8 Aug 2025 16:56:02 +0200 Message-Id: <20250808145602.41716-12-anthony@xenproject.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250808145602.41716-1-anthony@xenproject.org> References: <20250808145602.41716-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1754665257916116600 Content-Type: text/plain; charset="utf-8" From: Anthony PERARD Signed-off-by: Anthony PERARD --- CHANGELOG.md | 2 ++ README | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f31ca08fe..83195e2dae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepach= angelog.com/en/1.0.0/) - For x86, GCC 5.1 and Binutils 2.25, or Clang/LLVM 11 - For ARM32 and ARM64, GCC 5.1 and Binutils 2.25 - Linux based device model stubdomains are now fully supported. + - New dependency on library json-c, the toolstack will prefer it to `YAJL` + when available. =20 - On x86: - Restrict the cache flushing done as a result of guest physical memory= map diff --git a/README b/README index 6ee58f7b35..9329f30e13 100644 --- a/README +++ b/README @@ -53,7 +53,7 @@ provided by your OS distributor: * Development install of Python 2.7 or later (e.g., python-dev) * Development install of curses (e.g., libncurses-dev) * Development install of uuid (e.g. uuid-dev) - * Development install of yajl (e.g. libyajl-dev) + * Development install of json-c (e.g. libjson-c-dev) or yajl (e.g. lib= yajl-dev) * Development install of libaio (e.g. libaio-dev) version 0.3.107 or greater. * Development install of GLib v2.0 (e.g. libglib2.0-dev) --=20 Anthony PERARD