aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_utils.h
diff options
context:
space:
mode:
authorDario Faggioli <raistlin@linux.it>2012-07-06 13:17:44 +0100
committerDario Faggioli <raistlin@linux.it>2012-07-06 13:17:44 +0100
commit8cea5d337f061c39ec2c639f262becd49dafe361 (patch)
tree0eeafad91dc3845ed65cb9b656f76fa78addf492 /tools/libxl/libxl_utils.h
parente9ca00107ce06dfb9c624dab4664724ffeeb74e5 (diff)
downloadxen-8cea5d337f061c39ec2c639f262becd49dafe361.tar.gz
xen-8cea5d337f061c39ec2c639f262becd49dafe361.tar.bz2
xen-8cea5d337f061c39ec2c639f262becd49dafe361.zip
libxl: introduce some node map helpers
To allow for allocating a node specific libxl_bitmap (as it is for cpu number and maps). Helper unctions to convert a node map it its coresponding cpu map and vice versa are also implemented. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_utils.h')
-rw-r--r--tools/libxl/libxl_utils.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index b2c5ec783b..8fee567611 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -104,6 +104,29 @@ static inline int libxl_cpu_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *cpumap,
return libxl_bitmap_alloc(ctx, cpumap, max_cpus);
}
+static inline int libxl_node_bitmap_alloc(libxl_ctx *ctx,
+ libxl_bitmap *nodemap,
+ int max_nodes)
+{
+ if (max_nodes < 0)
+ return ERROR_INVAL;
+ if (max_nodes == 0)
+ max_nodes = libxl_get_max_nodes(ctx);
+ if (max_nodes == 0)
+ return ERROR_FAIL;
+
+ return libxl_bitmap_alloc(ctx, nodemap, max_nodes);
+}
+
+/* Populate cpumap with the cpus spanned by the nodes in nodemap */
+int libxl_nodemap_to_cpumap(libxl_ctx *ctx,
+ const libxl_bitmap *nodemap,
+ libxl_bitmap *cpumap);
+/* Populate nodemap with the nodes of the cpus in cpumap */
+int libxl_cpumap_to_nodemap(libxl_ctx *ctx,
+ const libxl_bitmap *cpuemap,
+ libxl_bitmap *nodemap);
+
static inline uint32_t libxl__sizekb_to_mb(uint32_t s) {
return (s + 1023) / 1024;
}