On 28/04/2023 11:41 am, Alejandro Vallejo wrote:
> xc_domain_getinfolist() internally relies on a sysctl that performs
> a linear search for the domids. Many callers of xc_domain_getinfolist()
> who require information about a precise domid are much better off calling
> xc_domain_getinfo_single() instead, that will use the getdomaininfo domctl
> instead and ensure the returned domid matches the requested one. The domtctl
> will find the domid faster too, because that uses hashed lists.
>
> Signed-off-by: Alejandro Vallejo <[email protected]>
> ---
> Cc: Andrew Cooper <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: Anthony PERARD <[email protected]>
> Cc: Juergen Gross <[email protected]>
> ---
>  tools/libs/light/libxl_dom.c         | 15 +++++----------
>  tools/libs/light/libxl_dom_suspend.c |  7 +------
>  tools/libs/light/libxl_domain.c      | 13 +++++--------
>  tools/libs/light/libxl_mem.c         |  4 ++--
>  tools/libs/light/libxl_sched.c       | 12 ++++--------
>  tools/xenpaging/xenpaging.c          | 10 +++++-----
>  6 files changed, 22 insertions(+), 39 deletions(-)
>
> diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c
> index 25fb716084..bd5d823581 100644
> --- a/tools/libs/light/libxl_dom.c
> +++ b/tools/libs/light/libxl_dom.c
> @@ -32,8 +32,8 @@ libxl_domain_type libxl__domain_type(libxl__gc *gc, 
> uint32_t domid)
>      xc_domaininfo_t info;
>      int ret;
>  
> -    ret = xc_domain_getinfolist(ctx->xch, domid, 1, &info);
> -    if (ret != 1 || info.domain != domid) {
> +    ret = xc_domain_getinfo_single(ctx->xch, domid, &info);
> +    if (ret < 0) {
>          LOG(ERROR, "unable to get domain type for domid=%"PRIu32, domid);

I think this LOG() would benefit from turning into a LOGED() like the
others.

Otherwise, everything LGTM.  I'm happy to adjust on commit.

Reviewed-by: Andrew Cooper <[email protected]>

Reply via email to