[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 05/17] libxc/libxl: allow to retrieve the number of online pCPUs
by introducing introduce xc_get_online_cpus() and libxl_get_online_cpus(). Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> --- Changes from v4: * introduced the xc call and call it from libxl, as suggested during review. --- tools/libxc/xc_misc.c | 10 ++++++++++ tools/libxc/xenctrl.h | 3 +++ tools/libxl/libxl.h | 3 +++ tools/libxl/libxl_utils.c | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c index c771469..00cd0d8 100644 --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -38,6 +38,16 @@ int xc_get_max_cpus(xc_interface *xch) return -1; } +int xc_get_online_cpus(xc_interface *xch) +{ + xc_physinfo_t physinfo; + + if ( !xc_physinfo(xch, &physinfo) ) + return physinfo.nr_cpus; + + return -1; +} + int xc_get_max_nodes(xc_interface *xch) { static int max_nodes = 0; diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 4ac6b8a..733ed03 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -356,6 +356,9 @@ typedef uint8_t *xc_cpumap_t; /* return maximum number of cpus the hypervisor supports */ int xc_get_max_cpus(xc_interface *xch); +/* return the number of online cpus */ +int xc_get_online_cpus(xc_interface *xch); + /* return array size for cpumap */ int xc_get_cpumap_size(xc_interface *xch); diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index bf311fe..a0d0908 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_online_cpus(libxl_ctx *ctx); + /* 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 0833de2..c9cef66 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -776,6 +776,13 @@ int libxl_get_max_cpus(libxl_ctx *ctx) return max_cpus < 0 ? ERROR_FAIL : max_cpus; } +int libxl_get_online_cpus(libxl_ctx *ctx) +{ + int online_cpus = xc_get_online_cpus(ctx->xch); + + return online_cpus < 0 ? ERROR_FAIL : online_cpus; +} + 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |