From patchwork Wed Apr 27 19:27:17 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: 8962241 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 840809F1C1 for ; Wed, 27 Apr 2016 19:30:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8EB2420259 for ; Wed, 27 Apr 2016 19:30:54 +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 9722C2028D for ; Wed, 27 Apr 2016 19:30:53 +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 1avV8f-00050a-Ry; Wed, 27 Apr 2016 19:28:45 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avV8f-0004xR-00 for xen-devel@lists.xenproject.org; Wed, 27 Apr 2016 19:28:45 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 0F/D7-02978-CE211275; Wed, 27 Apr 2016 19:28:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeJIrShJLcpLzFFi42LpnVTnqvtaSDH cYPJNVYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeN4f2ZBh1LFknWLWRsYD0t1MXJyCAm0MUks 2CAEYX9jlPj8SreLkQvI3sgo0bBgAQuE080oMftNKxNEVZHEjym9jF2MHBxsAiYSb1Y5goRFB JYzSrw4kwdSzyzQxCix5OcZdpCEsIC3xIoNC5lA6lkEVCWWnQ0ECfMKuEkc+baWHSQsISAnse BCOojJCRR+sy4aYpGrxMMr31lAbAkBQ4nTD7cxTmDkX8DIsIpRvTi1qCy1SNdML6koMz2jJDc xM0fX0MBYLze1uDgxPTUnMalYLzk/dxMjMGzqGRgYdzBeaXM+xCjJwaQkyrvhj0K4EF9Sfkpl RmJxRnxRaU5q8SFGGQ4OJQnejYKK4UKCRanpqRVpmTnAAIZJS3DwKInwloOkeYsLEnOLM9MhU qcYFaXEeSeCJARAEhmleXBtsKi5xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmY9yrIFJ7MvB K46a+AFjMBLb58SBZkcUkiQkqqgVH9w44dSsVLOL66zftZ+oV9+b5vHhZlSU/OJqvWbJu/4Zs 0p2r+lKvfTtYrRl+t7qt9YLQ5KVD20MPcKZKNjRzqRx6drWF36JStfmY2d/ndqfI7Y7dvYlh0 WbfdT256vvfFp5stNL/0x+ybce2lk+6+NtG0jJ4o5oP+n6Lk33O6RfM8fs8UK6/EUpyRaKjFX FScCAAxkNbolQIAAA== X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1461785321!29761119!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: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17745 invoked from network); 27 Apr 2016 19:28:43 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-16.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Apr 2016 19:28:43 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u3RJS2am031106 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Apr 2016 19:28:03 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u3RJS2ov027919 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Apr 2016 19:28:02 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u3RJS2ik012716; Wed, 27 Apr 2016 19:28:02 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 27 Apr 2016 12:28:01 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id 22D7B6A0141; Wed, 27 Apr 2016 15:27:59 -0400 (EDT) From: Konrad Rzeszutek Wilk To: konrad@kernel.org, xen-devel@lists.xenproject.org, sasha.levin@oracle.com, andrew.cooper3@citrix.com, ross.lagerwall@citrix.com, mpohlack@amazon.de Date: Wed, 27 Apr 2016 15:27:17 -0400 Message-Id: <1461785241-4481-21-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461785241-4481-1-git-send-email-konrad.wilk@oracle.com> References: <1461785241-4481-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: Wei Liu , Ian Jackson , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v10 20/24] libxl: info: Display build_id of the hypervisor. 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: 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/ And actually use the proper Style! v8: VERSION_OP was reverted, resurrect v3 version. v9: Made the if (r) LOGEV adhere to StyleGuide --- tools/libxl/libxl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl.h | 6 ++++++ 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 eec899d..c39d745 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5353,6 +5353,38 @@ libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr) return ret; } +static const int libxl__xc_version_wrap(libxl__gc *gc, libxl_version_info *info, + xen_build_id_t *build) +{ + int r; + + r = xc_version(CTX->xch, XENVER_build_id, build); + switch (r) { + case -EPERM: + case -ENODATA: + case 0: + info->build_id = libxl__strdup(NOGC, ""); + break; + + case -ENOBUFS: + break; + + default: + 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", build->buf[i]); + + r = 0; + } + break; + } + return r; +} + const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) { GC_INIT(ctx); @@ -5363,8 +5395,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 r; libxl_version_info *info = &ctx->version_info; if (info->xen_version_extra != NULL) @@ -5397,6 +5431,16 @@ 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); + r = libxl__xc_version_wrap(gc, info, &u.build_id); + if (r == -ENOBUFS) { + xen_build_id_t *build_id; + + build_id = libxl__zalloc(gc, info->pagesize); + build_id->len = info->pagesize - sizeof(*build_id); + r = libxl__xc_version_wrap(gc, info, build_id); + if (r) LOGEV(ERROR, r, "getting build_id"); + } out: GC_FREE; return info; diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 8ff5f31..2c0f868 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -247,6 +247,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 c3161f3..9840f3b 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -365,6 +365,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 dfb1b01..03ab644 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -5923,6 +5923,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; }