diff mbox series

[v3,08/10] tools: Introduce a non-truncating xc_xenver_changeset()

Message ID 20230815210650.2735671-9-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series Non-truncating XENVER_* subops | expand

Commit Message

Andrew Cooper Aug. 15, 2023, 9:06 p.m. UTC
Update libxl and the ocaml stubs to match.  No API/ABI change in either.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
---
CC: Wei Liu <wl@xen.org>
CC: Anthony PERARD <anthony.perard@citrix.com>
CC: Juergen Gross <jgross@suse.com>
CC: Christian Lindig <christian.lindig@citrix.com>
CC: David Scott <dave@recoil.org>
CC: Edwin Torok <edvin.torok@citrix.com>
CC: Rob Hoes <Rob.Hoes@citrix.com>
---
 tools/include/xenctrl.h             |  1 +
 tools/libs/ctrl/xc_version.c        |  5 +++++
 tools/libs/light/libxl.c            |  5 +----
 tools/ocaml/libs/xc/xenctrl_stubs.c | 19 ++++++++-----------
 4 files changed, 15 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 9bd5eed7397a..0400d65acaed 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -1599,6 +1599,7 @@  int xc_version(xc_interface *xch, int cmd, void *arg);
  */
 char *xc_xenver_extraversion(xc_interface *xch);
 char *xc_xenver_capabilities(xc_interface *xch);
+char *xc_xenver_changeset(xc_interface *xch);
 
 int xc_flask_op(xc_interface *xch, xen_flask_op_t *op);
 
diff --git a/tools/libs/ctrl/xc_version.c b/tools/libs/ctrl/xc_version.c
index 512302a393ea..9f2cae03dba8 100644
--- a/tools/libs/ctrl/xc_version.c
+++ b/tools/libs/ctrl/xc_version.c
@@ -161,3 +161,8 @@  char *xc_xenver_capabilities(xc_interface *xch)
 {
     return varbuf_simple_string(xch, XENVER_capabilities2);
 }
+
+char *xc_xenver_changeset(xc_interface *xch)
+{
+    return varbuf_simple_string(xch, XENVER_changeset2);
+}
diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c
index ae6c5e04cd59..9a3532ce139a 100644
--- a/tools/libs/light/libxl.c
+++ b/tools/libs/light/libxl.c
@@ -583,7 +583,6 @@  const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
     GC_INIT(ctx);
     union {
         xen_compile_info_t xen_cc;
-        xen_changeset_info_t xen_chgset;
         xen_platform_parameters_t p_parms;
         xen_commandline_t xen_commandline;
         xen_build_id_t build_id;
@@ -608,9 +607,7 @@  const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
     info->compile_date = libxl__strdup(NOGC, u.xen_cc.compile_date);
 
     info->capabilities = xc_xenver_capabilities(ctx->xch);
-
-    xc_version(ctx->xch, XENVER_changeset, &u.xen_chgset);
-    info->changeset = libxl__strdup(NOGC, u.xen_chgset);
+    info->changeset = xc_xenver_changeset(ctx->xch);
 
     xc_version(ctx->xch, XENVER_platform_parameters, &u.p_parms);
     info->virt_start = u.p_parms.virt_start;
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index e8da7d18d29d..8495d5bd9892 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -1035,28 +1035,25 @@  CAMLprim value stub_xc_version_compile_info(value xch_val)
 }
 
 
-static value xc_version_single_string(value xch_val, int code, void *info)
+CAMLprim value stub_xc_version_changeset(value xch_val)
 {
 	CAMLparam1(xch_val);
+	CAMLlocal1(result);
 	xc_interface *xch = xch_of_val(xch_val);
-	int retval;
+	char *changeset;
 
 	caml_enter_blocking_section();
-	retval = xc_version(xch, code, info);
+	changeset = xc_xenver_changeset(xch);
 	caml_leave_blocking_section();
 
-	if (retval)
+	if (!changeset)
 		failwith_xc(xch);
 
-	CAMLreturn(caml_copy_string((char *)info));
-}
+	result = caml_copy_string(changeset);
 
+	free(changeset);
 
-CAMLprim value stub_xc_version_changeset(value xch_val)
-{
-	xen_changeset_info_t ci;
-
-	return xc_version_single_string(xch_val, XENVER_changeset, &ci);
+	CAMLreturn(result);
 }