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

Re: [Xen-devel] [PATCH v4 03/15] libxl: introduce libxl_get_nr_cpus()



On Fri, 2013-11-22 at 19:56 +0100, Dario Faggioli wrote:
> to retrieve the actual number of pCPUs on the host.
> 
> Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
> ---
>  tools/libxl/libxl.h       |    3 +++
>  tools/libxl/libxl_utils.c |   18 ++++++++++++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index a9663e4..2fab5ba 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -652,6 +652,9 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, 
> libxl_domain_create_in
>  /* get max. number of cpus supported by hypervisor */
>  int libxl_get_max_cpus(libxl_ctx *ctx);
>  
> +/* get the actual number of online cpus on the host */
> +int libxl_get_nr_cpus(libxl_ctx *ctx);

I suggest get_online_cpus if that is what it returns. "nr" could be
counting various different types of cpu.


> +
>  /* get max. number of NUMA nodes supported by hypervisor */
>  int libxl_get_max_nodes(libxl_ctx *ctx);
>  
> diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
> index 1815422..8763070 100644
> --- a/tools/libxl/libxl_utils.c
> +++ b/tools/libxl/libxl_utils.c
> @@ -774,6 +774,24 @@ int libxl_get_max_cpus(libxl_ctx *ctx)
>      return max_cpus <= 0 ? ERROR_FAIL : max_cpus;
>  }
>  
> +int libxl_get_nr_cpus(libxl_ctx *ctx)

Arguably for consistency with the existing interfaces this should be a
wrapper around a (new) libxc function, but lets not go there today.

> +{
> +    GC_INIT(ctx);
> +    xc_physinfo_t physinfo = { 0 };

I don't think this initialiser is actually needed (nowhere in libxc does
it).

> +    int rc = 0;
> +
> +    if (xc_physinfo(ctx->xch, &physinfo)) {
> +        LOGE(ERROR, "xc_physinfo failed.");
> +        rc = ERROR_FAIL;
> +        goto out;
> +    }
> +    rc = physinfo.nr_cpus;
> +
> + out:
> +    GC_FREE;
> +    return rc;
> +}
> +
>  int libxl_get_max_nodes(libxl_ctx *ctx)
>  {
>      int max_nodes = xc_get_max_nodes(ctx->xch);
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel



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