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;
/* 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);
/* get max. number of cpus supported by hypervisor */
int libxl_get_max_cpus(libxl_ctx *ctx);
+/* get the actual number of currently online cpus on the host */
+int libxl_get_online_cpus(libxl_ctx *ctx);
+ /* Beware that no locking or serialization is provided by libxl,
+ * so the information can be outdated as far as the function
+ * returns. If there are other entities in the system capable
+ * of onlining/offlining CPUs, it is up to the application
+ * to guarantee consistency, if that is important. */
+
/* get max. number of NUMA nodes supported by hypervisor */
int libxl_get_max_nodes(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);