diff options
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; } |