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

Re: [Xen-devel] [PATCH RFC v1 05/13] libxc: introduce a domain loader for HVM guest firmware



. 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.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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