From: Wei Liu Subject: Re: [PATCH v5 08/28] libxc: introduce a xc_dom_arch for hvm-3.0-x86_32 guests Date: Tue, 25 Aug 2015 10:17:24 +0100 Message-ID: <20150825091724.GH29776@zion.uk.xensource.com> References: <1440176021-18910-1-git-send-email-roger.pau@citrix.com> <1440176021-18910-9-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZUAU0-00022B-LY for xen-devel@lists.xenproject.org; Tue, 25 Aug 2015 09:25:32 +0000 Content-Disposition: inline In-Reply-To: <1440176021-18910-9-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: xen-devel@lists.xenproject.org, Wei Liu , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Fri, Aug 21, 2015 at 06:53:21PM +0200, Roger Pau Monne wrote: > This xc_dom_arch will be used in order to build HVM domains. The code is > based on the existing xc_hvm_populate_memory and xc_hvm_populate_params > functions. > = > Signed-off-by: Roger Pau Monn=E9 > Reviewed-by: Andrew Cooper > Cc: Ian Jackson > Cc: Stefano Stabellini > Cc: Ian Campbell > Cc: Wei Liu > --- > Changes since v4: > - Replace a malloc+memset with a calloc. > - Remove a !=3D NULL check. > - Add Andrew Cooper Reviewed-by. > = > Changes since v3: > - Make sure c/s b9dbe33 is not reverted on this patch. > - Set the initial BSP state using {get/set}hvmcontext. [...] > +static int vcpu_hvm(struct xc_dom_image *dom) > +{ > + struct { > + struct hvm_save_descriptor header_d; > + HVM_SAVE_TYPE(HEADER) header; > + struct hvm_save_descriptor cpu_d; > + HVM_SAVE_TYPE(CPU) cpu; > + struct hvm_save_descriptor end_d; > + HVM_SAVE_TYPE(END) end; > + } bsp_ctx; > + uint8_t *full_ctx =3D NULL; > + int rc; > + > + DOMPRINTF_CALLED(dom->xch); > + > + /* > + * Get the full HVM context in order to have the header, it is not > + * possible to get the header with getcontext_partial, and crafting = one > + * from userspace is also not an option since cpuid is trapped and > + * modified by Xen. > + */ > + > + rc =3D xc_domain_hvm_getcontext(dom->xch, dom->guest_domid, NULL, 0); > + if ( rc <=3D 0 ) > + { > + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, > + "%s: unable to fetch HVM context size (rc=3D%d)", > + __func__, rc); > + return rc; Please avoid mixing return and goto when handling error cases. Use goto style is preferred. > + } > + > + full_ctx =3D calloc(1, rc); > + if ( full_ctx =3D=3D NULL ) > + { > + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, > + "%s: unable to allocate memory for HVM context (rc= =3D%d)", > + __func__, rc); > + return -ENOMEM; Ditto. And you can also remove "if ( full_ctx )" in out path. With those fixed: Acked-by: Wei Liu Wei.