|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 03/15] libxl: introduce libxl_get_nr_cpus()
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);
+
/* 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)
+{
+ GC_INIT(ctx);
+ xc_physinfo_t physinfo = { 0 };
+ 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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |