From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH v3 3/3] libxl: info: Display build_id of the hypervisor. Date: Mon, 11 Jan 2016 14:12:23 +0000 Message-ID: <20160111141223.GP26419@citrix.com> References: <1452219920-14043-1-git-send-email-konrad.wilk@oracle.com> <1452219920-14043-4-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aIdCv-0005tL-Cc for xen-devel@lists.xenproject.org; Mon, 11 Jan 2016 14:12:29 +0000 Content-Disposition: inline In-Reply-To: <1452219920-14043-4-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, mpohlack@amazon.de, JBeulich@suse.com, xen-devel@lists.xenproject.org, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On Thu, Jan 07, 2016 at 09:25:20PM -0500, Konrad Rzeszutek Wilk wrote: > 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/ > --- > tools/libxl/libxl.c | 24 ++++++++++++++++++++++++ > tools/libxl/libxl.h | 5 +++++ > tools/libxl/libxl_types.idl | 1 + > tools/libxl/xl_cmdimpl.c | 1 + > 4 files changed, 31 insertions(+) > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index 9207621..b894c1f 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -5263,6 +5263,7 @@ libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr) > > 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; > @@ -5270,8 +5271,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) > @@ -5304,6 +5307,27 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx) > xc_version(ctx->xch, XENVER_commandline, &u.xen_commandline); > info->commandline = strdup(u.xen_commandline); > > + u.build_id.len = sizeof(u) - sizeof(u.build_id); > + ret = xc_version(ctx->xch, XENVER_build_id, &u.build_id); > + switch ( ret ) { > + case -EPERM: > + case -ENODATA: > + case 0: > + info->build_id = strdup(""); I guess you're following existing strdup examples in this function. Since now there is a GC in scope, you can use libxl__strdup. Presumably you can also change other instances to use libxl__strdup. Wei.