From: Wei Liu Subject: Re: [PATCH v4 31/31] libxl: allow the creation of HVM domains without a device model. Date: Fri, 7 Aug 2015 13:58:05 +0100 Message-ID: <20150807125805.GR6005@zion.uk.xensource.com> References: <1438942688-7610-1-git-send-email-roger.pau@citrix.com> <1438942688-7610-32-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.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZNhDv-00080t-EW for xen-devel@lists.xenproject.org; Fri, 07 Aug 2015 12:58:11 +0000 Content-Disposition: inline In-Reply-To: <1438942688-7610-32-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 07, 2015 at 12:18:08PM +0200, Roger Pau Monne wrote: > Replace the firmware loaded into HVM guests with an OS kernel. Since the = HVM > builder now uses the PV xc_dom_* set of functions this kernel will be par= sed > and loaded inside the guest like on PV, but the container is a pure HVM > guest. > = > Also, if device_model_version is set to none or a device model for the > specified domain is not present unconditinally set the nic type to > LIBXL_NIC_TYPE_VIF. > = > Signed-off-by: Roger Pau Monn=E9 > Cc: Ian Jackson > Cc: Stefano Stabellini > Cc: Ian Campbell > Cc: Wei Liu > --- > Changes since v3: > - Add explicit /* fall through */ comments. > - Expand libxl__device_nic_setdefault so that it sets the right nic type > for HVMlite guests. > - Remove stray space in hvm_build_set_params. > - Fix the error paths of libxl__domain_firmware. > --- > docs/man/xl.cfg.pod.5 | 5 ++++ > tools/libxc/xc_dom_x86.c | 7 +++++ > tools/libxl/libxl.c | 39 ++++++++++++++----------- > tools/libxl/libxl_create.c | 16 ++++++++++- > tools/libxl/libxl_dm.c | 13 ++++++++- > tools/libxl/libxl_dom.c | 68 ++++++++++++++++++++++++++++++--------= ------ > tools/libxl/libxl_internal.h | 5 +++- > tools/libxl/libxl_types.idl | 1 + > tools/libxl/libxl_x86.c | 4 ++- > tools/libxl/xl_cmdimpl.c | 2 ++ > 10 files changed, 118 insertions(+), 42 deletions(-) > = > diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 > index 80e51bb..8cd7726 100644 > --- a/docs/man/xl.cfg.pod.5 > +++ b/docs/man/xl.cfg.pod.5 > @@ -1741,6 +1741,11 @@ This device-model is the default for Linux dom0. > Use the device-model based upon the historical Xen fork of Qemu. > This device-model is still the default for NetBSD dom0. > = > +=3Ditem B > + > +Don't use any device model. This requires a kernel capable of booting > +in this mode. booting without emulated devices? > + > =3Dback > = > It is recommended to accept the default value for new guests. If > diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c > index 1599de4..d67feb0 100644 > --- a/tools/libxc/xc_dom_x86.c > +++ b/tools/libxc/xc_dom_x86.c > @@ -1269,6 +1269,13 @@ static int meminit_hvm(struct xc_dom_image *dom) > if ( nr_pages > target_pages ) > memflags |=3D XENMEMF_populate_on_demand; > = > + /* Make sure there's a MMIO hole for the special pages. */ > + if ( dom->mmio_size =3D=3D 0 ) > + { > + dom->mmio_size =3D NR_SPECIAL_PAGES << PAGE_SHIFT; > + dom->mmio_start =3D special_pfn(0); > + } > + Better to just assert(dom->mmio_size !=3D 0); It's really libxl's responsibility to generate memory layout for guest. Libxc doesn't have all information to make the decision. > if ( dom->nr_vmemranges =3D=3D 0 ) > { > /* Build dummy vnode information > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index 083f099..a01868a 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -1033,11 +1033,13 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t= domid) > } > = > if (type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { > - rc =3D libxl__domain_resume_device_model(gc, domid); > - if (rc < 0) { > - LOG(ERROR, "failed to unpause device model for domain %u:%d", > - domid, rc); > - goto out; > + if (libxl__domain_has_device_model(gc, domid)) { Checking for device model version is not enough? > + rc =3D libxl__domain_resume_device_model(gc, domid); > + if (rc < 0) { > + LOG(ERROR, "failed to unpause device model for domain %u= :%d", > + domid, rc); > + goto out; > + } > } > } > ret =3D xc_domain_unpause(ctx->xch, domid); > @@ -1567,7 +1569,6 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__d= estroy_domid_state *dis) > libxl_ctx *ctx =3D CTX; > uint32_t domid =3D dis->domid; > char *dom_path; > - char *pid; > int rc, dm_present; > = > libxl__ev_child_init(&dis->destroyer); > @@ -1584,14 +1585,13 @@ void libxl__destroy_domid(libxl__egc *egc, libxl_= _destroy_domid_state *dis) > = > switch (libxl__domain_type(gc, domid)) { > case LIBXL_DOMAIN_TYPE_HVM: > - if (!libxl_get_stubdom_id(CTX, domid)) > - dm_present =3D 1; > - else > + if (libxl_get_stubdom_id(CTX, domid)) { > dm_present =3D 0; > - break; > + break; > + } > + /* fall through */ > case LIBXL_DOMAIN_TYPE_PV: > - pid =3D libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "/local/= domain/%d/image/device-model-pid", domid)); > - dm_present =3D (pid !=3D NULL); > + dm_present =3D libxl__domain_has_device_model(gc, domid); > break; > case LIBXL_DOMAIN_TYPE_INVALID: > rc =3D ERROR_FAIL; > @@ -3203,7 +3203,7 @@ out: > /***********************************************************************= *******/ > = > int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, > - uint32_t domid) > + uint32_t domid, libxl_domain_build_info= *info) > { > int rc; > = > @@ -3240,8 +3240,15 @@ int libxl__device_nic_setdefault(libxl__gc *gc, li= bxl_device_nic *nic, > = > switch (libxl__domain_type(gc, domid)) { > case LIBXL_DOMAIN_TYPE_HVM: > - if (!nic->nictype) > - nic->nictype =3D LIBXL_NIC_TYPE_VIF_IOEMU; > + if (!nic->nictype) { > + if (info !=3D NULL && > + info->device_model_version !=3D LIBXL_DEVICE_MODEL_VERSI= ON_NONE) > + nic->nictype =3D LIBXL_NIC_TYPE_VIF_IOEMU; > + else if (libxl__domain_has_device_model(gc, domid)) > + nic->nictype =3D LIBXL_NIC_TYPE_VIF_IOEMU; > + else > + nic->nictype =3D LIBXL_NIC_TYPE_VIF; I think all you need is to pass in device model version and if version !=3D none nictype =3D ioemu else nictype =3D vif ? Otherwise the code suggests that there can be case you have specified a device model when creating a domain but it somehow disappears when domain is running? Wei.