[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH 06/11] libxl: convert libxl__json_object_to_yajl_gen to libxl__json_object_to_libjsonc_object


  • To: Anthony PERARD <anthony@xxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 27 Aug 2025 11:37:07 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cauu/1sD6x5Xsm1QY3slDeJ6UwWu5fLIFTlv4uWdWQ0=; b=q5Ngb56HzQllnfAf/CB8ERft6HXKAk98XEco24ZMPvNt05fKO7OkQLH3zlSFBbFItvn4pVXANUnxJ3e44+6SLfzlfPEj6dozTlI3IQBeEiSo7xvfAbMh+RlEz5wg/mQGsS1f+HS3M7pxqElqyELK3zs1VKh8ILloaKmbjffcBm/fRKWuUbbYHkeSeWHwqup3/3H38OtbSFy92RK6RAcfmPS9PhoJLtlK36yp3NWZ6dxyGEl+bObPx1dpGP6z0CzUlnN+FaJQmE9Bw+RLWgfu+HXhvPGkDqlc6K95frGG+AB6cJB028rgl7VjQhI1TiIlxA96Q4GmCinLAiLh9POftw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LX9Ub0LI0CKeK8OuiOYtKCPaoig5Ua7Kq9vrIjWsMy3Np9naSOoIIadj3eM7Vku6dag/pDYjdmYnTaUxDiK/RUsC9MsLjnx/Miy4TjaTxKZIV8p4vM3RPhurMfw3pdff5zoirkw2zIByBhZatcOeovMmcqBiqov9ApOL3yBXfcuz8+GYRQZQKFMGyY/rg4k4LAvFGGIe/F8M+TqmyuazyPiKN4iAdiUuZYKrwzDjBqFCdOxzIN/6zdpbdM300+V80tWXeP7BJaVJACavIYvqJLpBzEdisFg7bV6gKs3/0FuyUVmFC5NF8MvL25NTSTM+mLaHu7ewbutyowMEJX19jQ==
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Wed, 27 Aug 2025 15:37:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-08-08 10:55, Anthony PERARD wrote:
From: Anthony PERARD <anthony.perard@xxxxxxxxxx>

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 <anthony.perard@xxxxxxxxxx>
---

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 char 
*key,
      return NULL;
  }
+#ifdef HAVE_LIBJSONC
+int libxl__json_object_to_json_object(libxl__gc *gc,
+                                      json_object **jso_out,
+                                      const libxl__json_object *obj)
+{
+    int idx = 0;
+    int rc, r;
+
+    switch (obj->type) {
+    case JSON_NULL:
+        *jso_out = json_object_new_null();
+        return 0;
+    case JSON_BOOL:
+        *jso_out = json_object_new_boolean(obj->u.b);
+        if (!*jso_out)
+            return ERROR_NOMEM;
+        return 0;
+    case JSON_INTEGER:
+        *jso_out = json_object_new_int64(obj->u.i);
+        if (!*jso_out)
+            return ERROR_NOMEM;
+        return 0;
+    case JSON_DOUBLE:
+        *jso_out = json_object_new_double(obj->u.d);
+        if (!*jso_out)
+            return ERROR_NOMEM;
+        return 0;
+    case JSON_NUMBER:
+        *jso_out = json_object_new_string(obj->u.string);

Is JSON_NUMBER calling json_object_new_string() correct? It looks like the yajl code falls back to a string, so that is okay but surprising.

So I just want to double check.  If so:

Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>

Thanks,
Jason

+        if (!*jso_out)
+            return ERROR_NOMEM;
+        return 0;



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.