From 8fedbbdb67434a5e1c81c23dfb1f744843a74091 Mon Sep 17 00:00:00 2001 From: Luyao Huang Date: Tue, 5 May 2015 18:13:38 +0800 Subject: [PATCH] conf: Add the cpu duplicate use check for vm numa settings https://bugzilla.redhat.com/show_bug.cgi?id=1176020 We had a check for the vcpu count total number in before, however this check is not good enough. There are some examples: 1. one of cpu id is out of maxvcpus, can set success(cpu count = 5 < 10): 10 2. use the same cpu in 2 cell, can set success(cpu count = 8 < 10): 10 3. use the same cpu in 2 cell, cannot set success(cpu count = 11 > 10): 10 Add a check for numa cpus, check if duplicate use one cpu in more than one cell. Signed-off-by: Luyao Huang Signed-off-by: Michal Privoznik --- src/conf/numa_conf.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 7ad3f661da..e4dc2f88ed 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -692,6 +692,7 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def, def->nmem_nodes = n; for (i = 0; i < n; i++) { + size_t j; int rc; unsigned int cur_cell = i; @@ -738,6 +739,15 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def, } VIR_FREE(tmp); + for (j = 0; j < i; j++) { + if (virBitmapOverlaps(def->mem_nodes[j].cpumask, + def->mem_nodes[i].cpumask)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("NUMA cells %zu and %zu have overlapping vCPU ids"), i, j); + goto cleanup; + } + } + ctxt->node = nodes[i]; if (virDomainParseMemory("./@memory", "./@unit", ctxt, &def->mem_nodes[cur_cell].mem, true, false) < 0)