From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v1 4/4] libxl: info: Display build_id of the hypervisor. Date: Fri, 9 Oct 2015 14:16:39 +0100 Message-ID: <1444396599.1410.395.camel@citrix.com> References: <1444359390-14153-1-git-send-email-konrad.wilk@oracle.com> <1444359390-14153-5-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.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZkXY5-0000ZT-7i for xen-devel@lists.xenproject.org; Fri, 09 Oct 2015 13:17:25 +0000 In-Reply-To: <1444359390-14153-5-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 , xen-devel@lists.xenproject.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, mpohlack@amazon.de, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On Thu, 2015-10-08 at 22:56 -0400, Konrad Rzeszutek Wilk wrote: > If the hypervisor is built with we will display it. I think there is a word missing in this sentence. Perhaps "it" after "with", or better "a build_id" or "blah blah feature enabled". > @@ -5295,8 +5298,21 @@ 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); > > + rc = xc_version_len(ctx->xch, XENVER_build_id, &u.build_id, BUILD_ID_LEN); Please see tools/libxl/CODING_STYLE. A variable called rc must only ever contain libxl error codes (ERROR_*), which xc_version_len does not return. "r" or "ret" is appropriate for the return value from a system call or xc_*. > + if (rc > 0) { Do you intentionally silently ignore a failure here? I think at the very least you should LOG all but the ones which are expected and which you have deemed tolerable. > + unsigned int i; > + > + info->build_id = (char *)malloc((rc * 2) + 1); Lack of an error check here, but in any case libxl__zalloc(NOGC, ...) instead, so it isn't needed anyway. > + > + for (i = 0; i < rc && (i + 1) * 2 < BUILD_ID_LEN; i++) > + snprintf(&info->build_id[i * 2], 3, "%02hhx", > u.build_id[i]); > + > + info->build_id[i*2]='\0'; You can drop after switching to libxl__zalloc, since the buffer starts out zeroed. diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl > index d6ef9a2..232749b 100644 > --- a/tools/libxl/libxl_types.idl > +++ b/tools/libxl/libxl_types.idl > @@ -353,6 +353,7 @@ libxl_version_info = Struct("version_info", [ > ("virt_start", uint64), > ("pagesize", integer), > ("commandline", string), > + ("build_id", string), A #define LIBXL_HAVE_* in libxl.h is required to signal the presence of this new field.