[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH for-4.10 1/3] libxc: panic when trying to create a PVH guest without kernel support



Roger Pau Monne:
> Previously when trying to boot a PV capable but not PVH capable kernel
> inside of a PVH container xc_dom_guest_type would succeed and return a
> PV guest type, which would lead to failures later on in the build
> process.
> 
> Instead provide a clear error message when trying to create a PVH
> guest using a kernel that doesn't support PVH.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  tools/libxc/xc_dom_elfloader.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xc_dom_elfloader.c
> index 62d421a5e3..568d7f370c 100644
> --- a/tools/libxc/xc_dom_elfloader.c
> +++ b/tools/libxc/xc_dom_elfloader.c
> @@ -59,6 +59,13 @@ static char *xc_dom_guest_type(struct xc_dom_image *dom,
>      if ( dom->container_type == XC_DOM_HVM_CONTAINER &&
>           dom->parms.phys_entry != UNSET_ADDR32 )
>          return "hvm-3.0-x86_32";
> +    if ( dom->container_type == XC_DOM_HVM_CONTAINER )
> +    {
> +        xc_dom_panic(dom->xch, XC_INVALID_KERNEL,
> +                     "%s: image not capable of booting inside a HVM 
> container",
> +                     __FUNCTION__);
> +        return "xen-3.0-unknown";
> +    }
>  
>      switch ( machine )
>      {

With this xc_dom_parse_elf_kernel() still returns success and the domain
build fails only later because of the "xen-3.0-unknown" type. Why not
fail directly in xc_dom_parse_elf_kernel() like for elf files which miss
the DomU feature?

And while we are at it: libxl__build_dom() expects that
xc_dom_parse_elf_kernel() sets an errno. Currently this can contain an
unrelated error since it does not get set when returning -EINVAL.

The following seems to work fine for me:

diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xc_dom_elfloader.c
index 568d7f370c..b67b95eb19 100644
--- a/tools/libxc/xc_dom_elfloader.c
+++ b/tools/libxc/xc_dom_elfloader.c
@@ -64,7 +64,8 @@ static char *xc_dom_guest_type(struct xc_dom_image *dom,
         xc_dom_panic(dom->xch, XC_INVALID_KERNEL,
                      "%s: image not capable of booting inside a HVM container",
                      __FUNCTION__);
-        return "xen-3.0-unknown";
+        errno = EINVAL;
+        return NULL;
     }
 
     switch ( machine )
@@ -195,6 +196,8 @@ static elf_errorstatus xc_dom_parse_elf_kernel(struct 
xc_dom_image *dom)
     dom->kernel_seg.vend   = dom->parms.virt_kend;
 
     dom->guest_type = xc_dom_guest_type(dom, elf);
+    if (dom->guest_type == NULL)
+        return -EINVAL;
     DOMPRINTF("%s: %s: 0x%" PRIx64 " -> 0x%" PRIx64 "",
               __FUNCTION__, dom->guest_type,
               dom->kernel_seg.vstart, dom->kernel_seg.vend);

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.