[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 14/23] libxl: info: Display build_id of the hypervisor.
If the hypervisor is built with we will display it. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> --- v2: Include HAVE_*, use libxl_zalloc, s/rc/ret/ v3: Retry with different size if 1020 is not enough. --- tools/libxl/libxl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl.h | 5 +++++ tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 1 + 4 files changed, 52 insertions(+) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 2d18b8d..4efd8dd 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5256,6 +5256,38 @@ libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr) return ret; } +static const int libxl_get_build_id(libxl_ctx *ctx, libxl_version_info *info, + xen_build_id_t *build) +{ + GC_INIT(ctx); + int ret; + + ret = xc_version(ctx->xch, XENVER_build_id, build); + switch ( ret ) { + case -EPERM: + case -ENODATA: + case 0: + info->build_id = libxl__strdup(NOGC, ""); + break; + case -ENOBUFS: + GC_FREE; + return -ENOBUFS; + default: + if (ret > 0) { + unsigned int i; + + info->build_id = libxl__zalloc(NOGC, (ret * 2) + 1); + + for (i = 0; i < ret ; i++) + snprintf(&info->build_id[i * 2], 3, "%02hhx", build->buf[i]); + } else + LOGEV(ERROR, ret, "getting build_id"); + break; + } + GC_FREE; + return 0; +} + const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) { GC_INIT(ctx); @@ -5266,8 +5298,10 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) xen_capabilities_info_t xen_caps; xen_platform_parameters_t p_parms; xen_commandline_t xen_commandline; + xen_build_id_t build_id; } u; long xen_version; + int ret; libxl_version_info *info = &ctx->version_info; if (info->xen_version_extra != NULL) @@ -5300,6 +5334,17 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline); info->commandline = libxl__strdup(NOGC, u.xen_commandline); + u.build_id.len = sizeof(u) - sizeof(u.build_id); + ret = libxl_get_build_id(ctx, info, &u.build_id); + if ( ret == -ENOBUFS ) { + xen_build_id_t *build_id; + + build_id = libxl__zalloc(gc, info->pagesize); + build_id->len = info->pagesize - sizeof(*build_id); + ret = libxl_get_build_id(ctx, info, build_id); + if ( ret ) + LOGEV(ERROR, ret, "getting build_id"); + } out: GC_FREE; return info; diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index fa87f53..b713407 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -218,6 +218,11 @@ #define LIBXL_HAVE_SOFT_RESET 1 /* + * LIBXL_HAVE_BUILD_ID means that libxl_version_info has the extra + * field for the hypervisor build_id. + */ +#define LIBXL_HAVE_BUILD_ID 1 +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 9ad7eba..92bf620 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -356,6 +356,7 @@ libxl_version_info = Struct("version_info", [ ("virt_start", uint64), ("pagesize", integer), ("commandline", string), + ("build_id", string), ], dir=DIR_OUT) libxl_domain_create_info = Struct("domain_create_info",[ diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index d07ccb2..9bdc42a 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -5552,6 +5552,7 @@ static void output_xeninfo(void) printf("cc_compile_by : %s\n", info->compile_by); printf("cc_compile_domain : %s\n", info->compile_domain); printf("cc_compile_date : %s\n", info->compile_date); + printf("build_id : %s\n", info->build_id); return; } -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |