diff options
author | Yang Zhang <yang.z.zhang@Intel.com> | 2012-06-28 17:47:13 +0100 |
---|---|---|
committer | Yang Zhang <yang.z.zhang@Intel.com> | 2012-06-28 17:47:13 +0100 |
commit | 928c75ce59fc11c707b8bfd0b99ce0c07ab89926 (patch) | |
tree | ac46f583868400516b25bba67a19915c7888df1c /tools/libxl/libxl_utils.c | |
parent | 8f7e8f7b56f62eb7fe7d459424b9f56466faaefb (diff) | |
download | xen-928c75ce59fc11c707b8bfd0b99ce0c07ab89926.tar.gz xen-928c75ce59fc11c707b8bfd0b99ce0c07ab89926.tar.bz2 xen-928c75ce59fc11c707b8bfd0b99ce0c07ab89926.zip |
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 <yang.z.zhang@Intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_utils.c')
-rw-r--r-- | tools/libxl/libxl_utils.c | 12 |
1 files changed, 6 insertions, 6 deletions
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; } |