[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xl: error out if vNUMA specifies more vcpus than pcpus
commit 51086e196ee6531f7cb45f23943dc8daf2d1527b Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Mon Aug 17 19:57:00 2015 +0100 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Fri Aug 21 08:45:55 2015 +0100 xl: error out if vNUMA specifies more vcpus than pcpus ... but allow user to override that check by specifying maxvcpus= in xl configuration file. Note that the code is constructed such that the fallout is dealt with after parsing. We can live with that because though it wastes a bit of cpu cycles but it is still functionally correct and I would like to have a clear split between parsing and dealing with fallouts. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Reviewed-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libxl/xl_cmdimpl.c | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 44fff82..ebbb9a5 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1175,6 +1175,14 @@ static void parse_vnuma_config(const XLU_Config *config, for (j = 0; j < len; j++) { parse_range(cpu_spec_list[j], &s, &e); for (; s <= e; s++) { + /* + * Note that if we try to set a bit beyond + * the size of bitmap, libxl_bitmap_set + * has no effect. The resulted bitmap + * doesn't reflect what user wants. The + * fallout is dealt with later after + * parsing. + */ libxl_bitmap_set(&vcpu_parsed[i], s); max_vcpus++; } @@ -1202,11 +1210,27 @@ static void parse_vnuma_config(const XLU_Config *config, } /* User has specified maxvcpus= */ - if (b_info->max_vcpus != 0 && b_info->max_vcpus != max_vcpus) { - fprintf(stderr, "xl: vnuma vcpus and maxvcpus= mismatch\n"); - exit(1); - } else + if (b_info->max_vcpus != 0) { + if (b_info->max_vcpus != max_vcpus) { + fprintf(stderr, "xl: vnuma vcpus and maxvcpus= mismatch\n"); + exit(1); + } + } else { + int host_cpus = libxl_get_online_cpus(ctx); + + if (host_cpus < 0) { + fprintf(stderr, "Failed to get online cpus\n"); + exit(1); + } + + if (host_cpus < max_vcpus) { + fprintf(stderr, "xl: vnuma specifies more vcpus than pcpus, "\ + "use maxvcpus= to override this check.\n"); + exit(1); + } + b_info->max_vcpus = max_vcpus; + } /* User has specified maxmem= */ if (b_info->max_memkb != LIBXL_MEMKB_DEFAULT && -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |