From patchwork Thu Mar 24 20:00:33 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: 8664211 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 4F2BA9F326 for ; Thu, 24 Mar 2016 20:03:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C40920382 for ; Thu, 24 Mar 2016 20:03:32 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 812CB201F5 for ; Thu, 24 Mar 2016 20:03:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajBRY-0007QF-TN; Thu, 24 Mar 2016 20:01:20 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajBRX-0007O5-EP for xen-devel@lists.xenproject.org; Thu, 24 Mar 2016 20:01:19 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id BF/22-04065-E8744F65; Thu, 24 Mar 2016 20:01:18 +0000 X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1458849676!33743544!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26163 invoked from network); 24 Mar 2016 20:01:18 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 24 Mar 2016 20:01:18 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2OK17th011532 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Mar 2016 20:01:07 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u2OK16XT013781 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Mar 2016 20:01:06 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u2OK16LG023724; Thu, 24 Mar 2016 20:01:06 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Mar 2016 13:01:06 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id 073146A00E8; Thu, 24 Mar 2016 16:01:04 -0400 (EDT) From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, ross.lagerwall@citrix.com, konrad@kernel.org, andrew.cooper3@citrix.com, mpohlack@amazon.de, sasha.levin@oracle.com Date: Thu, 24 Mar 2016 16:00:33 -0400 Message-Id: <1458849640-22588-22-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458849640-22588-1-git-send-email-konrad.wilk@oracle.com> References: <1458849640-22588-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: Wei Liu , Stefano Stabellini , Ian Jackson , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v5 21/28] libxl: info: Display build_id of the hypervisor using XEN_VERSION_build_id X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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 Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Stefano Stabellini Cc: Wei Liu v2: Include HAVE_*, use libxl_zalloc, s/rc/ret/ v3: Retry with different size if 1020 is not enough. v4: Use VERSION_OP subops instead of the XENVER_ subops v5: Change it per Wei's review. s/VERSION_OP/VERSION/ --- tools/libxl/libxl.c | 21 +++++++++++++++++++-- tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 6c3ec40..310a7f3 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5235,6 +5235,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) GC_INIT(ctx); char *buf; xen_version_op_val_t val = 0; + int r; libxl_version_info *info = &ctx->version_info; if (info->xen_version_extra != NULL) @@ -5277,8 +5278,24 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) info->virt_start = val; - (void)libxl__xc_version_wrapper(gc, XEN_VERSION_commandline, buf, - info->pagesize, &info->commandline); + if (libxl__xc_version_wrapper(gc, XEN_VERSION_commandline, buf, + info->pagesize, &info->commandline) < 0) + goto out; + + r = xc_version(ctx->xch, XEN_VERSION_build_id, buf, info->pagesize); + if (r < 0) + { + info->build_id = libxl__strdup(NOGC, ""); + } + else if (r > 0) + { + unsigned int i; + + info->build_id = libxl__zalloc(NOGC, (r * 2) + 1); + + for (i = 0; i < r; i++) + snprintf(&info->build_id[i * 2], 3, "%02hhx", buf[i]); + } out: GC_FREE; return info; diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index f61bc4b..5baffdf 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -230,6 +230,12 @@ #define LIBXL_HAVE_APIC_ASSIST 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 59b183c..e3a5707 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -363,6 +363,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 a3610fc..23da95e 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -5861,6 +5861,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; }