tools: Switch to non-truncating XENVER_* ops
cover tools: Switch to non-truncating XENVER_* ops
This is the tools side of the Xen series posted previously.
With this, a Xen built with long strings can be retrieved:
# xl info ... xen_version : 4.18-unstable+REALLY LONG EXTRAVERSION xen_changeset : Tue Jan 3 19:27:17 2023 git:52d2da6c0544+REALLY SUPER DUPER EXTRA MEGA LONG CHANGESET ...
Andrew Cooper (6):
tools/libxc: Move xc_version() out of xc_private.c into its own file
tools: Introduce a non-truncating xc_xenver_extraversion()
tools: Introduce a non-truncating xc_xenver_capabilities()
tools: Introduce a non-truncating xc_xenver_changeset()
tools: Introduce a non-truncating xc_xenver_cmdline()
tools: Introduce a xc_xenver_buildid() wrapper
tools/include/xenctrl.h | 10 ++ tools/libs/ctrl/Makefile.common | 1 + tools/libs/ctrl/xc_private.c | 66 ------------ tools/libs/ctrl/xc_private.h | 7 -- tools/libs/ctrl/xc_version.c | 206 ++++++++++++++++++++++++++++++++++++ tools/libs/light/libxl.c | 61 +---------- tools/ocaml/libs/xc/xenctrl_stubs.c | 45 +++++--- 7 files changed, 250 insertions(+), 146 deletions(-) create mode 100644 tools/libs/ctrl/xc_version.c
Signature · 1 line
2.11.0
PATCH 1/6 tools/libxc: Move xc_version() out of xc_private.c into its own file
kexec-tools uses xc_version(), meaning that it is not a private API. As we're going to extend the functionality substantially, move it to its own file.
---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
--- tools/libs/ctrl/Makefile.common | 1 + tools/libs/ctrl/xc_private.c | 66 -------------------------------- tools/libs/ctrl/xc_private.h | 7 ---- tools/libs/ctrl/xc_version.c | 83 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 73 deletions(-) create mode 100644 tools/libs/ctrl/xc_version.c
tools/libs/ctrl/Makefile.common +1 -0
@@ -16,6 +16,7 @@ OBJS-y += xc_pm.o OBJS-y += xc_cpu_hotplug.o OBJS-y += xc_vm_event.o OBJS-y += xc_vmtrace.o +OBJS-y += xc_version.o OBJS-y += xc_monitor.o OBJS-y += xc_mem_paging.o OBJS-y += xc_mem_access.o
tools/libs/ctrl/xc_private.c +0 -66
72 lines not on this page · raw message
tools/libs/ctrl/xc_private.h +0 -7
@@ -215,13 +215,6 @@ void xc__hypercall_buffer_cache_release(xc_interface *xch);* Hypercall interfaces. */ -static inline int do_xen_version (xc_interface *xch,int cmd,xc_hypercall_buffer_t *dest) -{ -DECLARE_HYPERCALL_BUFFER_ARGUMENT (dest); -return xencall2 (xch->xcall, __HYPERVISOR_xen_version, - cmd,HYPERCALL_BUFFER_AS_ARG (dest)); -} -static inline int do_physdev_op (xc_interface *xch,int cmd,void *op,size_t len) {int ret =-1 ;
tools/libs/ctrl/xc_version.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 1/6] tools/libxc: Move xc_version() out of xc_private.c into its own file
Quoted 4 lines · Andrew Cooper
kexec-tools uses
xc_version(), meaning that it is not a private API. As we're going to extend the functionality substantially, move it to its own file.Signed-off-by Andrew Cooper <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 2/6 tools: Introduce a non-truncating xc_xenver_extraversion()
In reply to Andrew Cooper... which uses XENVER_extraversion2.
In order to do sensibly, use manual hypercall buffer handling. Not only does this avoid an extra bounce buffer (we need to strip the xen_varbuf_t header anyway), it's also shorter and easlier to follow.
Update libxl and the ocaml stubs to match. No API/ABI change in either.
With this change made, xl info can now correctly access a >15 char extraversion:
# xl info xen_version 4.18-unstable+REALLY LONG EXTRAVERSION
---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: David Scott <[email protected]>
CC: Edwin Torok <[email protected]>
CC: Rob Hoes <[email protected]>
Note: There is a marginal risk for a memory leak in the ocaml bindings, but it turns out we have the same bug elsewhere and fixing that is going to be rather complicated.
--- tools/include/xenctrl.h | 6 +++ tools/libs/ctrl/xc_version.c | 75 +++++++++++++++++++++++++++++++++++++ tools/libs/light/libxl.c | 4 +- tools/ocaml/libs/xc/xenctrl_stubs.c | 9 +++-- 4 files changed, 87 insertions(+), 7 deletions(-)
tools/include/xenctrl.h +6 -0
@@ -1604,6 +1604,12 @@ long xc_memory_op(xc_interface *xch, unsigned int cmd, void *arg, size_t len);int xc_version (xc_interface *xch,int cmd,void *arg); +/* +* Wrappers around XENVER_* subops. Callers must pass the returned pointer to +* free(). +*/ +char *xc_xenver_extraversion (xc_interface *xch); +int xc_flask_op (xc_interface *xch,xen_flask_op_t *op);/*
tools/libs/ctrl/xc_version.c +75 -0
78 lines not on this page · raw message
tools/libs/light/libxl.c +1 -3
@@ -581,7 +581,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) {GC_INIT (ctx);union { -xen_extraversion_t xen_extra;xen_compile_info_t xen_cc;xen_changeset_info_t xen_chgset;xen_capabilities_info_t xen_caps;
@@ -600,8 +599,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->xen_version_major = xen_version >>16 ; info->xen_version_minor = xen_version &0xFF ; -xc_version (ctx->xch, XENVER_extraversion, &u.xen_extra); - info->xen_version_extra =libxl__strdup (NOGC , u.xen_extra); + info->xen_version_extra =xc_xenver_extraversion (ctx->xch);xc_version (ctx->xch, XENVER_compile_info, &u.xen_cc); info->compiler =libxl__strdup (NOGC , u.xen_cc.compiler);
tools/ocaml/libs/xc/xenctrl_stubs.c +5 -4
@@ -929,9 +929,8 @@ CAMLprim value stub_xc_version_version(value xch) {CAMLparam1 (xch);CAMLlocal1 (result); -xen_extraversion_t extra; +char *extra;long packed; -int retval;caml_enter_blocking_section (); packed =xc_version (_H (xch), XENVER_version,NULL );
@@ -941,10 +940,10 @@ CAMLprim value stub_xc_version_version(value xch)failwith_xc (_H (xch));caml_enter_blocking_section (); - retval =xc_version (_H (xch), XENVER_extraversion, &extra); + extra =xc_xenver_extraversion (_H (xch));caml_leave_blocking_section (); -if (retval) +if (!extra)failwith_xc (_H (xch)); result =caml_alloc_tuple (3 );
@@ -953,6 +952,8 @@ CAMLprim value stub_xc_version_version(value xch)Store_field (result,1 ,Val_int (packed &0xffff ));Store_field (result,2 ,caml_copy_string (extra)); +free (extra); +CAMLreturn (result); }
Signature · 1 line
2.11.0
Re: [PATCH 2/6] tools: Introduce a non-truncating xc_xenver_extraversion()
Quoted 19 lines · Andrew Cooper
... which uses
XENVER_extraversion2.In order to do sensibly, use manual hypercall buffer handling. Not only does this avoid an extra bounce buffer (we need to strip the
xen_varbuf_theader anyway), it's also shorter and easlier to follow.Update libxl and the ocaml stubs to match. No API/ABI change in either.
With this change made,
xl infocan now correctly access a >15 char extraversion:# xl info xen_version 4.18-unstable+REALLY LONG EXTRAVERSIONSigned-off-by Andrew Cooper <[email protected]>
Quoted 8 lines
---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: David Scott <[email protected]>
CC: Edwin Torok <[email protected]>
CC: Rob Hoes <[email protected]>
Quoted 173 lines
Note: There is a marginal risk for a memory leak in the ocaml bindings, but it turns out we have the same bug elsewhere and fixing that is going to be rather complicated.
---tools/include/xenctrl.h | 6 +++ tools/libs/ctrl/xc_version.c | 75 +++++++++++++++++++++++++++++++++++++ tools/libs/light/libxl.c | 4 +- tools/ocaml/libs/xc/xenctrl_stubs.c | 9 +++-- 4 files changed, 87 insertions(+), 7 deletions(-)tools/include/xenctrl.h +6
-0@@ -1604,6 +1604,12 @@ long xc_memory_op(xc_interface *xch, unsigned int cmd, void *arg, size_t len);int xc_version (xc_interface *xch,int cmd,void *arg); +/* +* Wrappers around XENVER_* subops. Callers must pass the returned pointer to +* free(). +*/ +char *xc_xenver_extraversion (xc_interface *xch); +int xc_flask_op (xc_interface *xch,xen_flask_op_t *op);/* tools/libs/ctrl/xc_version.c +75
-0@@ -81,3 +81,78 @@ int xc_version(xc_interface *xch, int cmd, void *arg)return rc; } + +/* +* Raw hypercall wrapper, letting us pass NULL and things which aren't of +* xc_hypercall_buffer_t *. +*/ +static int do_xen_version_raw (xc_interface *xch,int cmd,void *hbuf) +{ +return xencall2 (xch->xcall, __HYPERVISOR_xen_version, + cmd, (unsigned long )hbuf); +} + +/* +* Issues a xen_varbuf_t subop, using manual hypercall buffer handling to +* avoid unnecessary buffering. +* +* On failure, returns NULL. errno probably useful. +* On success, returns a pointer which must be freed with xencall_free_buffer(). +*/ +static xen_varbuf_t *varbuf_op (xc_interface *xch,unsigned int subop) +{ +xen_varbuf_t *hbuf =NULL ; +ssize_t sz; + + sz =do_xen_version_raw (xch, subop,NULL ); +if ( sz <0 ) +return NULL ; + + hbuf =xencall_alloc_buffer (xch->xcall,sizeof (*hbuf) + sz); +if ( !hbuf ) +return NULL ; + + hbuf->len = sz; + + sz =do_xen_version_raw (xch, subop, hbuf); +if ( sz <0 ) + { +xencall_free_buffer (xch->xcall, hbuf); +return NULL ; + } + + hbuf->len = sz; +return hbuf; +} + +/* +* Wrap varbuf_op() to obtain a simple string. Copy out of the hypercall +* buffer, stripping the xen_varbuf_t header and appending a NUL terminator. +* +* On failure, returns NULL, errno probably useful. +* On success, returns a pointer which must be free()'d. +*/ +static char *varbuf_simple_string (xc_interface *xch,unsigned int subop) +{ +xen_varbuf_t *hbuf =varbuf_op (xch, subop); +char *res; + +if ( !hbuf ) +return NULL ; + + res =malloc (hbuf->len +1 ); +if ( res ) + { +memcpy (res, hbuf->buf, hbuf->len); + res[hbuf->len] ='\0' ; + } + +xencall_free_buffer (xch->xcall, hbuf); + +return res; +} + +char *xc_xenver_extraversion (xc_interface *xch) +{ +return varbuf_simple_string (xch, XENVER_extraversion2); +}tools/libs/light/libxl.c +1
-3@@ -581,7 +581,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) {GC_INIT (ctx);union { -xen_extraversion_t xen_extra;xen_compile_info_t xen_cc;xen_changeset_info_t xen_chgset;xen_capabilities_info_t xen_caps;@@ -600,8 +599,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->xen_version_major = xen_version >>16 ; info->xen_version_minor = xen_version &0xFF ; -xc_version (ctx->xch, XENVER_extraversion, &u.xen_extra); - info->xen_version_extra =libxl__strdup (NOGC , u.xen_extra); + info->xen_version_extra =xc_xenver_extraversion (ctx->xch);xc_version (ctx->xch, XENVER_compile_info, &u.xen_cc); info->compiler =libxl__strdup (NOGC , u.xen_cc.compiler);tools/ocaml/libs/xc/xenctrl_stubs.c +5
-4@@ -929,9 +929,8 @@ CAMLprim value stub_xc_version_version(value xch) {CAMLparam1 (xch);CAMLlocal1 (result); -xen_extraversion_t extra; +char *extra;long packed; -int retval;caml_enter_blocking_section (); packed =xc_version (_H (xch), XENVER_version,NULL );@@ -941,10 +940,10 @@ CAMLprim value stub_xc_version_version(value xch)failwith_xc (_H (xch));caml_enter_blocking_section (); - retval =xc_version (_H (xch), XENVER_extraversion, &extra); + extra =xc_xenver_extraversion (_H (xch));caml_leave_blocking_section (); -if (retval) +if (!extra)failwith_xc (_H (xch)); result =caml_alloc_tuple (3 );@@ -953,6 +952,8 @@ CAMLprim value stub_xc_version_version(value xch)Store_field (result,1 ,Val_int (packed &0xffff ));Store_field (result,2 ,caml_copy_string (extra)); +free (extra); +CAMLreturn (result); }Signature · 1 line
2.11.0
Re: [PATCH 2/6] tools: Introduce a non-truncating xc_xenver_extraversion()
In reply to Andrew CooperQuoted 8 lines · Andrew Cooper
... which uses
XENVER_extraversion2.In order to do sensibly, use manual hypercall buffer handling. Not only does this avoid an extra bounce buffer (we need to strip the
xen_varbuf_theader anyway), it's also shorter and easlier to follow.Update libxl and the ocaml stubs to match. No API/ABI change in either.
Quoted 7 lines
With this change made,
xl infocan now correctly access a >15 char extraversion:# xl info xen_version 4.18-unstable+REALLY LONG EXTRAVERSIONSigned-off-by Andrew Cooper <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 3/6 tools: Introduce a non-truncating xc_xenver_capabilities()
In reply to Andrew CooperUpdate libxl and the ocaml stubs to match. No API/ABI change in either.
---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: David Scott <[email protected]>
CC: Edwin Torok <[email protected]>
CC: Rob Hoes <[email protected]>
--- tools/include/xenctrl.h | 1 + tools/libs/ctrl/xc_version.c | 5 +++++ tools/libs/light/libxl.c | 4 +--- tools/ocaml/libs/xc/xenctrl_stubs.c | 17 +++++++++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-)
tools/include/xenctrl.h +1 -0
@@ -1609,6 +1609,7 @@ int xc_version(xc_interface *xch, int cmd, void *arg);* free(). */ char *xc_xenver_extraversion (xc_interface *xch); +char *xc_xenver_capabilities (xc_interface *xch);int xc_flask_op (xc_interface *xch,xen_flask_op_t *op);
tools/libs/ctrl/xc_version.c +5 -0
@@ -156,3 +156,8 @@ char *xc_xenver_extraversion(xc_interface *xch) {return varbuf_simple_string (xch, XENVER_extraversion2); } + +char *xc_xenver_capabilities (xc_interface *xch) +{ +return varbuf_simple_string (xch, XENVER_capabilities2); +}
tools/libs/light/libxl.c +1 -3
@@ -583,7 +583,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)union {xen_compile_info_t xen_cc;xen_changeset_info_t xen_chgset; -xen_capabilities_info_t xen_caps;xen_platform_parameters_t p_parms;xen_commandline_t xen_commandline;xen_build_id_t build_id;
@@ -607,8 +606,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->compile_domain =libxl__strdup (NOGC , u.xen_cc.compile_domain); info->compile_date =libxl__strdup (NOGC , u.xen_cc.compile_date); -xc_version (ctx->xch, XENVER_capabilities, &u.xen_caps); - info->capabilities =libxl__strdup (NOGC , u.xen_caps); + info->capabilities =xc_xenver_capabilities (ctx->xch);xc_version (ctx->xch, XENVER_changeset, &u.xen_chgset); info->changeset =libxl__strdup (NOGC , u.xen_chgset);
tools/ocaml/libs/xc/xenctrl_stubs.c +15 -2
@@ -1009,9 +1009,22 @@ CAMLprim value stub_xc_version_changeset(value xch) CAMLprim value stub_xc_version_capabilities(value xch) { -xen_capabilities_info_t ci; +CAMLparam1 (xch); +CAMLlocal1 (result); +char *capabilities; + +caml_enter_blocking_section (); + retval =xc_xenver_capabilities (_H (xch)); +caml_leave_blocking_section (); -return xc_version_single_string (xch, XENVER_capabilities, &ci); +if (!capabilities) +failwith_xc (_H (xch)); + + result =caml_copy_string (capabilities); + +free (capabilities); + +CAMLreturn (result); }
Signature · 1 line
2.11.0
Re: [PATCH 3/6] tools: Introduce a non-truncating xc_xenver_capabilities()
Quoted 16 lines · Andrew Cooper
Update libxl and the ocaml stubs to match. No API/ABI change in either.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: David Scott <[email protected]>
CC: Edwin Torok <[email protected]>
CC: Rob Hoes <[email protected]>
Quoted 6 lines
---
tools/include/xenctrl.h | 1 + tools/libs/ctrl/xc_version.c | 5 +++++ tools/libs/light/libxl.c | 4 +--- tools/ocaml/libs/xc/xenctrl_stubs.c | 17 +++++++++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-)
Quoted 80 lines
tools/include/xenctrl.h +1
-0@@ -1609,6 +1609,7 @@ int xc_version(xc_interface *xch, int cmd, void *arg);* free(). */ char *xc_xenver_extraversion (xc_interface *xch); +char *xc_xenver_capabilities (xc_interface *xch);int xc_flask_op (xc_interface *xch,xen_flask_op_t *op);tools/libs/ctrl/xc_version.c +5
-0@@ -156,3 +156,8 @@ char *xc_xenver_extraversion(xc_interface *xch) {return varbuf_simple_string (xch, XENVER_extraversion2); } + +char *xc_xenver_capabilities (xc_interface *xch) +{ +return varbuf_simple_string (xch, XENVER_capabilities2); +}tools/libs/light/libxl.c +1
-3@@ -583,7 +583,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)union {xen_compile_info_t xen_cc;xen_changeset_info_t xen_chgset; -xen_capabilities_info_t xen_caps;xen_platform_parameters_t p_parms;xen_commandline_t xen_commandline;xen_build_id_t build_id;@@ -607,8 +606,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->compile_domain =libxl__strdup (NOGC , u.xen_cc.compile_domain); info->compile_date =libxl__strdup (NOGC , u.xen_cc.compile_date); -xc_version (ctx->xch, XENVER_capabilities, &u.xen_caps); - info->capabilities =libxl__strdup (NOGC , u.xen_caps); + info->capabilities =xc_xenver_capabilities (ctx->xch);xc_version (ctx->xch, XENVER_changeset, &u.xen_chgset); info->changeset =libxl__strdup (NOGC , u.xen_chgset);tools/ocaml/libs/xc/xenctrl_stubs.c +15
-2@@ -1009,9 +1009,22 @@ CAMLprim value stub_xc_version_changeset(value xch) CAMLprim value stub_xc_version_capabilities(value xch) { -xen_capabilities_info_t ci; +CAMLparam1 (xch); +CAMLlocal1 (result); +char *capabilities; + +caml_enter_blocking_section (); + retval =xc_xenver_capabilities (_H (xch)); +caml_leave_blocking_section (); -return xc_version_single_string (xch, XENVER_capabilities, &ci); +if (!capabilities) +failwith_xc (_H (xch)); + + result =caml_copy_string (capabilities); + +free (capabilities); + +CAMLreturn (result); }Signature · 1 line
2.11.0
Re: [PATCH 3/6] tools: Introduce a non-truncating xc_xenver_capabilities()
In reply to Andrew CooperQuoted 3 lines · Andrew Cooper
Update libxl and the ocaml stubs to match. No API/ABI change in either.
Signed-off-by Andrew Cooper <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 4/6 tools: Introduce a non-truncating xc_xenver_changeset()
In reply to Andrew CooperUpdate libxl and the ocaml stubs to match. No API/ABI change in either.
---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: David Scott <[email protected]>
CC: Edwin Torok <[email protected]>
CC: Rob Hoes <[email protected]>
--- 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(-)
tools/include/xenctrl.h +1 -0
@@ -1610,6 +1610,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);
tools/libs/ctrl/xc_version.c +5 -0
@@ -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); +}
tools/libs/light/libxl.c +1 -4
@@ -582,7 +582,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;
@@ -607,9 +606,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;
tools/ocaml/libs/xc/xenctrl_stubs.c +8 -11
@@ -983,27 +983,24 @@ CAMLprim value stub_xc_version_compile_info(value xch) } -static value xc_version_single_string (value xch,int code,void *info) +CAMLprim value stub_xc_version_changeset(value xch) {CAMLparam1 (xch); -int retval; +CAMLlocal1 (result); +char *changeset;caml_enter_blocking_section (); - retval =xc_version (_H (xch), code, info); + retval =xc_xenver_changeset (_H (xch));caml_leave_blocking_section (); -if (retval) +if (!changeset)failwith_xc (_H (xch)); -CAMLreturn (caml_copy_string ((char *)info)); -} + result =caml_copy_string (changeset); +free (changeset); -CAMLprim value stub_xc_version_changeset(value xch) -{ -xen_changeset_info_t ci; - -return xc_version_single_string (xch, XENVER_changeset, &ci); +CAMLreturn (result); }
Signature · 1 line
2.11.0
Re: [PATCH 4/6] tools: Introduce a non-truncating xc_xenver_changeset()
Quoted 7 lines · Andrew Cooper
Update libxl and the ocaml stubs to match. No API/ABI change in either.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 106 lines
---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Christian Lindig <[email protected]>
CC: David Scott <[email protected]>
CC: Edwin Torok <[email protected]>
CC: Rob Hoes <[email protected]>
---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(-)tools/include/xenctrl.h +1
-0@@ -1610,6 +1610,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);tools/libs/ctrl/xc_version.c +5
-0@@ -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); +}tools/libs/light/libxl.c +1
-4@@ -582,7 +582,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;@@ -607,9 +606,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;tools/ocaml/libs/xc/xenctrl_stubs.c +8
-11@@ -983,27 +983,24 @@ CAMLprim value stub_xc_version_compile_info(value xch) } -static value xc_version_single_string (value xch,int code,void *info) +CAMLprim value stub_xc_version_changeset(value xch) {CAMLparam1 (xch); -int retval; +CAMLlocal1 (result); +char *changeset;caml_enter_blocking_section (); - retval =xc_version (_H (xch), code, info); + retval =xc_xenver_changeset (_H (xch));caml_leave_blocking_section (); -if (retval) +if (!changeset)failwith_xc (_H (xch)); -CAMLreturn (caml_copy_string ((char *)info)); -} + result =caml_copy_string (changeset); +free (changeset); -CAMLprim value stub_xc_version_changeset(value xch) -{ -xen_changeset_info_t ci; - -return xc_version_single_string (xch, XENVER_changeset, &ci); +CAMLreturn (result); }Signature · 1 line
2.11.0
Re: [PATCH 4/6] tools: Introduce a non-truncating xc_xenver_changeset()
In reply to Andrew CooperQuoted 3 lines · Andrew Cooper
Update libxl and the ocaml stubs to match. No API/ABI change in either.
Signed-off-by Andrew Cooper <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 5/6 tools: Introduce a non-truncating xc_xenver_cmdline()
In reply to Andrew CooperUpdate libxl to match. No API/ABI change.
---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
--- tools/include/xenctrl.h | 1 + tools/libs/ctrl/xc_version.c | 5 +++++ tools/libs/light/libxl.c | 4 +--- 3 files changed, 7 insertions(+), 3 deletions(-)
tools/include/xenctrl.h +1 -0
@@ -1611,6 +1611,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); +char *xc_xenver_commandline (xc_interface *xch);int xc_flask_op (xc_interface *xch,xen_flask_op_t *op);
tools/libs/ctrl/xc_version.c +5 -0
@@ -166,3 +166,8 @@ char *xc_xenver_changeset(xc_interface *xch) {return varbuf_simple_string (xch, XENVER_changeset2); } + +char *xc_xenver_commandline (xc_interface *xch) +{ +return varbuf_simple_string (xch, XENVER_commandline2); +}
tools/libs/light/libxl.c +1 -3
@@ -583,7 +583,6 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)union {xen_compile_info_t xen_cc;xen_platform_parameters_t p_parms; -xen_commandline_t xen_commandline;xen_build_id_t build_id; } u;long xen_version;
@@ -613,8 +612,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->pagesize =xc_version (ctx->xch, XENVER_pagesize,NULL ); -xc_version (ctx->xch, XENVER_commandline, &u.xen_commandline); - info->commandline =libxl__strdup (NOGC , u.xen_commandline); + info->commandline =xc_xenver_commandline (ctx->xch); u.build_id.len =sizeof (u) -sizeof (u.build_id); r =libxl__xc_version_wrap (gc, info, &u.build_id);
Signature · 1 line
2.11.0
Re: [PATCH 5/6] tools: Introduce a non-truncating xc_xenver_cmdline()
Quoted 3 lines · Andrew Cooper
Update libxl to match. No API/ABI change.
Signed-off-by Andrew Cooper <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 6/6 tools: Introduce a xc_xenver_buildid() wrapper
In reply to Andrew Cooper... which converts binary content to hex automatically.
Update libxl to match. No API/ABI change.
This removes a latent bug for cases when the buildid is longer than 4092 bytes.
---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
--- tools/include/xenctrl.h | 1 + tools/libs/ctrl/xc_version.c | 33 +++++++++++++++++++++++++++++++++ tools/libs/light/libxl.c | 44 +------------------------------------------- 3 files changed, 35 insertions(+), 43 deletions(-)
tools/include/xenctrl.h +1 -0
@@ -1612,6 +1612,7 @@ char *xc_xenver_extraversion(xc_interface *xch);char *xc_xenver_capabilities (xc_interface *xch);char *xc_xenver_changeset (xc_interface *xch);char *xc_xenver_commandline (xc_interface *xch); +char *xc_xenver_buildid (xc_interface *xch);int xc_flask_op (xc_interface *xch,xen_flask_op_t *op);
tools/libs/ctrl/xc_version.c +33 -0
@@ -171,3 +171,36 @@ char *xc_xenver_commandline(xc_interface *xch) {return varbuf_simple_string (xch, XENVER_commandline2); } + +static void str2hex (char *dst,const unsigned char *src,size_t n) +{ +static const unsigned char hex[] ="0123456789abcdef" ; + +for ( ; n; n-- ) + { +unsigned char c = *src++; + + *dst++ = hex[c >>4 ]; + *dst++ = hex[c &0xf ]; + } +} + +char *xc_xenver_buildid (xc_interface *xch) +{ +xen_varbuf_t *hbuf =varbuf_op (xch, XENVER_build_id); +char *res; + +if ( !hbuf ) +return NULL ; + + res =malloc ((hbuf->len *2 ) +1 ); +if ( res ) + { +str2hex (res, hbuf->buf, hbuf->len); + res[hbuf->len *2 ] ='\0' ; + } + +xencall_free_buffer (xch->xcall, hbuf); + +return res; +}
tools/libs/light/libxl.c +1 -43
63 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 6/6] tools: Introduce a xc_xenver_buildid() wrapper
Quoted 8 lines · Andrew Cooper
... which converts binary content to hex automatically.
Update libxl to match. No API/ABI change.
This removes a latent bug for cases when the buildid is longer than 4092 bytes.
Signed-off-by Andrew Cooper <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
I will look at individual patches, too.
Quoted 29 lines · Andrew Cooper
This is the tools side of the Xen series posted previously.
With this, a Xen built with long strings can be retrieved:
# xl info ... xen_version : 4.18-unstable+REALLY LONG EXTRAVERSION xen_changeset : Tue Jan 3 19:27:17 2023 git:52d2da6c0544+REALLY SUPER DUPER EXTRA MEGA LONG CHANGESET ...Andrew Cooper (6):
tools/libxc: Movexc_version()out ofxc_private.cinto its own file
tools: Introduce a non-truncatingxc_xenver_extraversion()
tools: Introduce a non-truncatingxc_xenver_capabilities()
tools: Introduce a non-truncatingxc_xenver_changeset()
tools: Introduce a non-truncatingxc_xenver_cmdline()
tools: Introduce axc_xenver_buildid()wrappertools/include/xenctrl.h | 10 ++ tools/libs/ctrl/Makefile.common | 1 + tools/libs/ctrl/xc_private.c | 66 ------------ tools/libs/ctrl/xc_private.h | 7 -- tools/libs/ctrl/xc_version.c | 206 ++++++++++++++++++++++++++++++++++++ tools/libs/light/libxl.c | 61 +---------- tools/ocaml/libs/xc/xenctrl_stubs.c | 45 +++++--- 7 files changed, 250 insertions(+), 146 deletions(-)
Quoted 5 lines
create mode 100644
tools/libs/ctrl/xc_version.cSignature · 1 line
2.11.0
Quoted 27 lines · Andrew Cooper
This is the tools side of the Xen series posted previously.
With this, a Xen built with long strings can be retrieved:
# xl info ... xen_version : 4.18-unstable+REALLY LONG EXTRAVERSION xen_changeset : Tue Jan 3 19:27:17 2023 git:52d2da6c0544+REALLY SUPER DUPER EXTRA MEGA LONG CHANGESET ...Andrew Cooper (6):
tools/libxc: Movexc_version()out ofxc_private.cinto its own file
tools: Introduce a non-truncatingxc_xenver_extraversion()
tools: Introduce a non-truncatingxc_xenver_capabilities()
tools: Introduce a non-truncatingxc_xenver_changeset()
tools: Introduce a non-truncatingxc_xenver_cmdline()
tools: Introduce axc_xenver_buildid()wrappertools/include/xenctrl.h | 10 ++ tools/libs/ctrl/Makefile.common | 1 + tools/libs/ctrl/xc_private.c | 66 ------------ tools/libs/ctrl/xc_private.h | 7 -- tools/libs/ctrl/xc_version.c | 206 ++++++++++++++++++++++++++++++++++++ tools/libs/light/libxl.c | 61 +---------- tools/ocaml/libs/xc/xenctrl_stubs.c | 45 +++++--- 7 files changed, 250 insertions(+), 146 deletions(-)
Quoted 2 lines
create mode 100644
tools/libs/ctrl/xc_version.c
Hmm, I'm not completely opposed to this, but do we really need all that additional code?
Apart from the build-id all the information is easily available via hypfs. And the build-id can be easily added to hypfs.
Juergen
Quoted 33 lines · Juergen Gross
Quoted 22 lines · Andrew Cooper
This is the tools side of the Xen series posted previously.
With this, a Xen built with long strings can be retrieved:
# xl info ... xen_version : 4.18-unstable+REALLY LONG EXTRAVERSION xen_changeset : Tue Jan 3 19:27:17 2023 git:52d2da6c0544+REALLY SUPER DUPER EXTRA MEGA LONG CHANGESET ...Andrew Cooper (6):
tools/libxc: Movexc_version()out ofxc_private.cinto its own file
tools: Introduce a non-truncatingxc_xenver_extraversion()
tools: Introduce a non-truncatingxc_xenver_capabilities()
tools: Introduce a non-truncatingxc_xenver_changeset()
tools: Introduce a non-truncatingxc_xenver_cmdline()
tools: Introduce axc_xenver_buildid()wrappertools/include/xenctrl.h | 10 ++
tools/libs/ctrl/Makefile.common | 1 +Quoted 9 lines
tools/libs/ctrl/xc_private.c | 66 ------------ tools/libs/ctrl/xc_private.h | 7 -- tools/libs/ctrl/xc_version.c | 206 ++++++++++++++++++++++++++++++++++++ tools/libs/light/libxl.c | 61 +---------- tools/ocaml/libs/xc/xenctrl_stubs.c | 45 +++++--- 7 files changed, 250 insertions(+), 146 deletions(-)create mode 100644
tools/libs/ctrl/xc_version.c
Quoted 4 lines
Hmm, I'm not completely opposed to this, but do we really need all that additional code?
Apart from the build-id all the information is easily available via hypfs.
capabilitiles at the very least isn't there. Not that I'm particularly complaining - its not an interface we want to encourage.
Quoted 1 line
And the build-id can be easily added to hypfs.
Hypfs is optional, and you will find firm resistance to making it mandatory for this.
Also, having looked at how hypfs_string_set_reference() works, it's not correct with livepatching (nothing updates size). I suspect this only impacts the livepatching "unit" tests which nothing runs (hence why livepatching is *still* broken on 4.15 and later).
~Andrew
Quoted 1 line · Andrew Cooper
This is the tools side of the Xen series posted previously.
There's also python bindings using xc_version(), is it something we want to update?
Cheers,
Signature · 1 line
Anthony PERARD