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

Re: [PATCH] tests/resource: Fix HVM guest in !SHADOW builds



On Thu, Feb 29, 2024 at 08:53:54PM +0000, Andrew Cooper wrote:
> Right now, test-resource always creates HVM Shadow guests.  But if Xen has
> SHADOW compiled out, running the test yields:
> 
>   $./test-resource
>   XENMEM_acquire_resource tests
>   Test x86 PV
>     Created d1
>     Test grant table
>   Test x86 PVH
>     Skip: 95 - Operation not supported
> 
> and doesn't really test HVM guests, but doesn't fail either.
> 
> There's nothing paging-mode-specific about this test, so default to HAP if
> possible and provide a more specific message if neither HAP or Shadow are
> available.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

One comment below.

> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> CC: Wei Liu <wl@xxxxxxx>
> ---
>  tools/tests/resource/test-resource.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/tools/tests/resource/test-resource.c 
> b/tools/tests/resource/test-resource.c
> index 7ae88ea34807..2796053588d3 100644
> --- a/tools/tests/resource/test-resource.c
> +++ b/tools/tests/resource/test-resource.c
> @@ -20,6 +20,8 @@ static xc_interface *xch;
>  static xenforeignmemory_handle *fh;
>  static xengnttab_handle *gh;
>  
> +static xc_physinfo_t physinfo;
> +
>  static void test_gnttab(uint32_t domid, unsigned int nr_frames,
>                          unsigned long gfn)
>  {
> @@ -172,6 +174,23 @@ static void test_domain_configurations(void)
>  
>          printf("Test %s\n", t->name);
>  
> +#if defined(__x86_64__) || defined(__i386__)
> +        /*
> +         * On x86, use HAP guests if possible, but skip if neither HAP nor
> +         * SHADOW is available.
> +         */
> +        if ( t->create.flags & XEN_DOMCTL_CDF_hvm )
> +        {
> +            if ( physinfo.capabilities & XEN_SYSCTL_PHYSCAP_hap )
> +                t->create.flags |= XEN_DOMCTL_CDF_hap;
> +            else if ( !(physinfo.capabilities & XEN_SYSCTL_PHYSCAP_shadow) )
> +            {
> +                printf("  Skip: Neither HAP or SHADOW available\n");
> +                continue;
> +            }
> +        }

Provided that you are already checking, might also be worth to keep in
mind that at some point we might want to also check for
XEN_SYSCTL_PHYSCAP_{hvm,pv} and skip those tests if the requested domain
type is not available.

Thanks, Roger.



 


Rackspace

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