From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH RFC v1 05/13] libxc: introduce a domain loader for HVM guest firmware Date: Fri, 10 Jul 2015 15:09:09 -0400 Message-ID: <20150710190909.GH30788@l.oracle.com> References: <1434989487-74940-1-git-send-email-roger.pau@citrix.com> <1434989487-74940-6-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZDdfj-0005Qo-CB for xen-devel@lists.xenproject.org; Fri, 10 Jul 2015 19:09:19 +0000 Content-Disposition: inline In-Reply-To: <1434989487-74940-6-git-send-email-roger.pau@citrix.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: Roger Pau Monne Cc: Elena Ufimtseva , Wei Liu , Ian Campbell , Stefano Stabellini , Andrew Cooper , Ian Jackson , Jan Beulich , xen-devel@lists.xenproject.org, Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org . snip.. > +static elf_negerrnoval check_elf_kernel(struct xc_dom_image *dom, bool verbose) why don't we want the verbose to be always true? > +{ > + if ( dom->kernel_blob == NULL ) > + { > + if ( verbose ) > + xc_dom_panic(dom->xch, > + XC_INTERNAL_ERROR, "%s: no kernel image loaded", > + __FUNCTION__); > + return -EINVAL; > + } > + > + if ( !elf_is_elfbinary(dom->kernel_blob, dom->kernel_size) ) > + { > + if ( verbose ) > + xc_dom_panic(dom->xch, > + XC_INVALID_KERNEL, "%s: kernel is not an ELF image", > + __FUNCTION__); > + return -EINVAL; > + } > + return 0; > +} > + > +static elf_negerrnoval xc_dom_probe_hvm_kernel(struct xc_dom_image *dom) > +{ > + struct elf_binary elf; > + int rc; > + > + /* This loader is designed for HVM guest firmware. */ > + if ( dom->container_type != XC_DOM_HVM_CONTAINER ) > + return -EINVAL; > + > + rc = check_elf_kernel(dom, 0); > + if ( rc != 0 ) > + return rc; > + > + rc = elf_init(&elf, dom->kernel_blob, dom->kernel_size); > + if ( rc != 0 ) > + return rc; > + > + /* > + * We need to check that there are no Xen ELFNOTES, or > + * else we might be trying to load a PV kernel. > + */ > + elf_parse_binary(&elf); > + rc = elf_xen_parse(&elf, &dom->parms); > + if ( rc == 0 ) > + return -EINVAL; > + > + return 0; > +} > + > +static elf_errorstatus xc_dom_parse_hvm_kernel(struct xc_dom_image *dom) > + /* > + * This function sometimes returns -1 for error and sometimes > + * an errno value. ?!?! The definition for this error type says: include/xen/libelf.h:typedef int elf_negerrnoval; /* 0: ok; -EFOO: error */ so it should be -EXX thought that is at odd with the libxc API - which is -1 for errors and errno carries the bug. But that would require xc_dom_parse return value to be 'int', not elf_errorstatus.