From nobody Tue Dec 16 08:32:44 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