]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Add the cpu duplicate use check for vm numa settings
authorLuyao Huang <lhuang@redhat.com>
Tue, 5 May 2015 10:13:38 +0000 (18:13 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 5 May 2015 11:31:47 +0000 (13:31 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1176020

We had a check for the vcpu count total number in <numa>
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):

<vcpu placement='static'>10</vcpu>
<cell id='0' cpus='0-3,100' memory='512000' unit='KiB'/>

2. use the same cpu in 2 cell, can set success(cpu count = 8 < 10):
<vcpu placement='static'>10</vcpu>
<cell id='0' cpus='0-3' memory='512000' unit='KiB'/>
<cell id='1' cpus='0-3' memory='512000' unit='KiB'/>

3. use the same cpu in 2 cell, cannot set success(cpu count = 11 > 10):
<vcpu placement='static'>10</vcpu>
<cell id='0' cpus='0-6' memory='512000' unit='KiB'/>
<cell id='1' cpus='0-3' memory='512000' unit='KiB'/>

Add a check for numa cpus, check if duplicate use one cpu in more
than one cell.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/numa_conf.c

index 7ad3f661da0672e61d182dba9526f2b9e77bd36c..e4dc2f88edbab24e2eb5f459cfffd9508106234f 100644 (file)
@@ -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)