From 928c75ce59fc11c707b8bfd0b99ce0c07ab89926 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Thu, 28 Jun 2012 17:47:13 +0100 Subject: libxl: allow to allocate cpumap with specific size Currently, libxl_cpumap_alloc()allocate the cpumap with size of number of physical cpus. In some place, we may want to allocate specific size of cpumap. This patch allow to pass a argument to specific the size that you want to allocate. If pass 0, it means the size is equal to number of physical cpus. Signed-off-by: Yang Zhang Acked-by: Ian Jackson Committed-by: Ian Jackson --- tools/libxl/libxl_utils.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tools/libxl/libxl_utils.c') diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 67ef82c8e4..2acf7d4a43 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -489,19 +489,19 @@ int libxl_mac_to_device_nic(libxl_ctx *ctx, uint32_t domid, return rc; } -int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap) +int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap, int max_cpus) { - int max_cpus; int sz; - max_cpus = libxl_get_max_cpus(ctx); + if (max_cpus < 0) + return ERROR_INVAL; + if (max_cpus == 0) + max_cpus = libxl_get_max_cpus(ctx); if (max_cpus == 0) return ERROR_FAIL; sz = (max_cpus + 7) / 8; - cpumap->map = calloc(sz, sizeof(*cpumap->map)); - if (!cpumap->map) - return ERROR_NOMEM; + cpumap->map = libxl__calloc(NULL, sizeof(*cpumap->map), sz); cpumap->size = sz; return 0; } -- cgit v1.2.3