From: Dario Faggioli Date: Fri, 13 Mar 2015 11:09:41 +0000 (+0100) Subject: xl: enable using ranges of pCPUs when creating cpupools X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3575 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a86eecbbf5155aa5b4ec02b6c5e41baf1a7f49de;p=xen.git xl: enable using ranges of pCPUs when creating cpupools instead of just list of single pCPUs or NUMA node IDs, as it happens right now. On the other hand, after this change, strings containing pCPUs and NUMA node ranges is supported. The syntax is the same one supported by the "cpus" and "cpus_soft" config switch, i.e., "4-8" or "node:1,12-18,^14". This make things more flexible, more consistent, and also improves error handling, as the pCPU range parsing routine already present in xl is more reliable than just a call to atoi(). While there, remove a redundant error check in the legacy syntax handling (libxl_bitmap_test() already checks the index being within the size of the bitmap). Signed-off-by: Dario Faggioli Cc: Ian Campbell Cc: Ian Jackson Cc: Stefano Stabellini Cc: Wei Liu Cc: Juergen Gross Acked-by: Wei Liu --- diff --git a/docs/man/xlcpupool.cfg.pod.5 b/docs/man/xlcpupool.cfg.pod.5 index bb15cbeaf5..2ff8ee87fb 100644 --- a/docs/man/xlcpupool.cfg.pod.5 +++ b/docs/man/xlcpupool.cfg.pod.5 @@ -93,10 +93,26 @@ Specifies the cpus of the NUMA-nodes given in C (an integer or a list of integers) to be member of the cpupool. The free cpus in the specified nodes are allocated in the new cpupool. -=item B +=item B -The specified C are allocated in the new cpupool. All cpus must -be free. Must not be specified together with B. +Specifies the cpus that will be member of the cpupool. All the specified +cpus must be free, or creation will fail. C may be specified +as follows: + +=over 4 + +=item ["2", "3", "5"] + +means that cpus 2,3,5 will be member of the cpupool. + +=item "0-3,5,^1" + +means that cpus 0,2,3 and 5 will be member of the cpupool. A "node:" or +"nodes:" modifier can be used. E.g., "0,node:1,nodes:2-3,^10-13" means +that pcpus 0, plus all the cpus of NUMA nodes 1,2,3 with the exception +of cpus 10,11,12,13 will be memeber of the cpupool. + +=back If neither B nor B are specified only the first free cpu found will be allocated in the new cpupool. diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 40ac8103b1..76224e0df4 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7341,18 +7341,29 @@ int main_cpupoolcreate(int argc, char **argv) fprintf(stderr, "no free cpu found\n"); goto out_cfg; } - } else if (!xlu_cfg_get_list(config, "cpus", &cpus, 0, 0)) { + } else if (!xlu_cfg_get_list(config, "cpus", &cpus, 0, 1)) { n_cpus = 0; while ((buf = xlu_cfg_get_listitem(cpus, n_cpus)) != NULL) { i = atoi(buf); - if ((i < 0) || (i >= freemap.size * 8) || - !libxl_bitmap_test(&freemap, i)) { + if ((i < 0) || !libxl_bitmap_test(&freemap, i)) { fprintf(stderr, "cpu %d illegal or not free\n", i); goto out_cfg; } libxl_bitmap_set(&cpumap, i); n_cpus++; } + } else if (!xlu_cfg_get_string(config, "cpus", &buf, 0)) { + if (cpurange_parse(buf, &cpumap)) + goto out_cfg; + + n_cpus = 0; + libxl_for_each_set_bit(i, cpumap) { + if (!libxl_bitmap_test(&freemap, i)) { + fprintf(stderr, "cpu %d illegal or not free\n", i); + goto out_cfg; + } + n_cpus++; + } } else n_cpus = 0;