diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index ff9ea77624..ffd94a8bd2 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -143,11 +143,15 @@ Combining this with "all" is also possible, meaning "all,^nodes:1" results in all the vcpus of the guest running on all the cpus on the host, except for the cpus belonging to the host NUMA node 1. -=item ["2", "3"] (or [2, 3]) +=item ["2", "3-8,^5"] -To ask for specific vcpu mapping. That means (in this example), vcpu #0 -of the guest will run on cpu #2 of the host and vcpu #1 of the guest will -run on cpu #3 of the host. +To ask for specific vcpu mapping. That means (in this example), vcpu 0 +of the guest will run on cpu 2 of the host and vcpu 1 of the guest will +run on cpus 3,4,6,7,8 of the host. + +More complex notation can be also used, exactly as described above. So +"all,^5-8", or just "all", or "node:0,node:2,^9-11,18-20" are all legal, +for each element of the list. =back diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index ad445b04c9..8c2ef074ed 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -808,16 +808,15 @@ static void parse_config_data(const char *config_source, b_info->vcpu_hard_affinity = xmalloc(num_cpus * sizeof(libxl_bitmap)); while ((buf = xlu_cfg_get_listitem(cpus, j)) != NULL && j < num_cpus) { - i = atoi(buf); - libxl_bitmap_init(&b_info->vcpu_hard_affinity[j]); if (libxl_cpu_bitmap_alloc(ctx, &b_info->vcpu_hard_affinity[j], 0)) { fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", j); exit(1); } - libxl_bitmap_set_none(&b_info->vcpu_hard_affinity[j]); - libxl_bitmap_set(&b_info->vcpu_hard_affinity[j], i); + + if (vcpupin_parse(buf, &b_info->vcpu_hard_affinity[j])) + exit(1); j++; } @@ -827,15 +826,31 @@ static void parse_config_data(const char *config_source, libxl_defbool_set(&b_info->numa_placement, false); } else if (!xlu_cfg_get_string (config, "cpus", &buf, 0)) { - if (libxl_cpu_bitmap_alloc(ctx, &b_info->cpumap, 0)) { - fprintf(stderr, "Unable to allocate cpumap\n"); + b_info->vcpu_hard_affinity = + xmalloc(b_info->max_vcpus * sizeof(libxl_bitmap)); + + libxl_bitmap_init(&b_info->vcpu_hard_affinity[0]); + if (libxl_cpu_bitmap_alloc(ctx, + &b_info->vcpu_hard_affinity[0], 0)) { + fprintf(stderr, "Unable to allocate cpumap for vcpu 0\n"); exit(1); } - libxl_bitmap_set_none(&b_info->cpumap); - if (vcpupin_parse(buf, &b_info->cpumap)) + if (vcpupin_parse(buf, &b_info->vcpu_hard_affinity[0])) exit(1); + for (i = 1; i < b_info->max_vcpus; i++) { + libxl_bitmap_init(&b_info->vcpu_hard_affinity[i]); + if (libxl_cpu_bitmap_alloc(ctx, + &b_info->vcpu_hard_affinity[i], 0)) { + fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", i); + exit(1); + } + libxl_bitmap_copy(ctx, &b_info->vcpu_hard_affinity[i], + &b_info->vcpu_hard_affinity[0]); + } + b_info->num_vcpu_hard_affinity = b_info->max_vcpus; + libxl_defbool_set(&b_info->numa_placement, false); }