From nobody Sat Oct 4 23:25:51 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=1759147703; cv=none; d=zohomail.com; s=zohoarc; b=NwXwzTf1wKGK2SanlF0B/5tuZ0pHc9dlXHL+y7P0JdMtgkKQRLiV9IS1PO8edFi+Q2YRcdg7wXyz/b/e2ykJXarrpRMBme5xyAv4VIKy7Cjbyq0nIAI+6ZpVBBLm4BwjdTp1WjjkoE+g8y4pfrDlJOXK8SZDVYN7oM7ve1qLW+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759147703; 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=7z8q2jx9Z85Tq8/zLDVB0fdB1L9QpzjX78jo8wa3bT0=; b=jPD99wHjsWHc4E2e/y6pgJ3bhnLv7JfXTQG0lXixBgtIWUPUCBMZamFWHZA+XwZ+BRNUISQstYjH5akVn6kvKyudha/pA8nDDrcOJARadM79HHp2Z3cDJ4Mol+XubJTr45eYlhOB4LWLEvrH1sV5J1oqDxkjcYgt2IzBQpq72Sk= 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 1759147703059826.8140830461826; Mon, 29 Sep 2025 05:08:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1132743.1471028 (Exim 4.92) (envelope-from ) id 1v3Cfm-00007n-BK; Mon, 29 Sep 2025 12:08:06 +0000 Received: by outflank-mailman (output) from mailman id 1132743.1471028; Mon, 29 Sep 2025 12:08:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v3Cfm-00007Y-6y; Mon, 29 Sep 2025 12:08:06 +0000 Received: by outflank-mailman (input) for mailman id 1132743; Mon, 29 Sep 2025 12:08:04 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v3Cfj-0008DS-V9 for xen-devel@lists.xenproject.org; Mon, 29 Sep 2025 12:08:03 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1v3Cfj-00GXBd-2J; Mon, 29 Sep 2025 12:08:03 +0000 Received: from [2a01:cb15:80df:da00:e2a9:ff82:7bde:38cd] (helo=l14.home) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v3Cfj-004JHo-2M; Mon, 29 Sep 2025 12:08:03 +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=7z8q2jx9Z85Tq8/zLDVB0fdB1L9QpzjX78jo8wa3bT0=; b=HLJzgLIkTM1mPA8GjhtyzC+/m4 0VNpQPeN7gQnNYhhNAzpn3Ws5GxjwgcrgWs7TXCSdFCCGXicnmq6TQkLj+Jr5e0eAE+e1qreco8r3 V/sz6dP7atBoaUyoaXNkMemnamn4zIIOffbkZBXvLeGuQ/6wnou2x5NlQaI6lBivewPg=; From: Anthony PERARD To: xen-devel@lists.xenproject.org Cc: Anthony PERARD , Jason Andryuk , Juergen Gross Subject: [XEN PATCH v2 5/8] libxl: convert libxl__json_object_to_json() to json_object Date: Mon, 29 Sep 2025 14:07:53 +0200 Message-ID: <20250929120756.46075-6-anthony@xenproject.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250929120756.46075-1-anthony@xenproject.org> References: <20250929120756.46075-1-anthony@xenproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1759147704187116600 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 eeda9c301d..c76ae9f64a 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) @@ -1527,6 +1529,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; @@ -1554,6 +1579,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