From patchwork Fri Feb 12 18:05:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 8294831 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8AD4A9F1E0 for ; Fri, 12 Feb 2016 18:08:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D01E20431 for ; Fri, 12 Feb 2016 18:08:57 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 619FA20421 for ; Fri, 12 Feb 2016 18:08:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUI7R-00069e-WC; Fri, 12 Feb 2016 18:07:02 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUI7K-00063u-31 for xen-devel@lists.xen.org; Fri, 12 Feb 2016 18:06:54 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id 42/D4-29985-D3F1EB65; Fri, 12 Feb 2016 18:06:53 +0000 X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1455300411!23472150!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40538 invoked from network); 12 Feb 2016 18:06:52 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 12 Feb 2016 18:06:52 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1CI6hrw025060 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 12 Feb 2016 18:06:44 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u1CI6hd0028677 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 12 Feb 2016 18:06:43 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u1CI6gI3017140; Fri, 12 Feb 2016 18:06:42 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Feb 2016 10:06:42 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id 8B3356A4BFD; Fri, 12 Feb 2016 13:06:40 -0500 (EST) From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, andrew.cooper3@citrix.com, konrad@kernel.org, mpohlack@amazon.de, ross.lagerwall@citrix.com, sasha.levin@citrix.com, jinsong.liu@alibaba-inc.com, Ian Jackson , Stefano Stabellini , Ian Campbell , Wei Liu , xen-devel@lists.xen.org Date: Fri, 12 Feb 2016 13:05:52 -0500 Message-Id: <1455300361-13092-15-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1455300361-13092-1-git-send-email-konrad.wilk@oracle.com> References: <1455300361-13092-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v3 14/23] libxl: info: Display build_id of the hypervisor. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the hypervisor is built with we will display it. Signed-off-by: Konrad Rzeszutek Wilk --- 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; }