]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Handle non-sequential NUMA node numbers
authorPradipta Kr. Banerjee <pradipta.banerjee@gmail.com>
Tue, 11 Feb 2014 14:32:50 +0000 (14:32 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 11 Feb 2014 14:44:20 +0000 (14:44 +0000)
On some platforms like IBM PowerNV the NUMA node numbers can be
non-sequential. For eg. numactl --hardware o/p from such a machine looks
as given below

node distances:
   node   0   1  16  17
     0:  10  40  40  40
     1:  40  10  40  40
    16:  40  40  10  40
    17:  40  40  40  10

The NUMA nodes are 0,1,16,17

Libvirt uses sequential index as NUMA node numbers and this can
result in crash or incorrect results.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
src/conf/capabilities.c
src/qemu/qemu_driver.c
src/qemu/qemu_process.c

index 726ec3fcdeba16b51a5f4a6fe6f66d2a095d91a3..78f65cbf663144fef3574087d804a96a96679280 100644 (file)
@@ -1000,10 +1000,18 @@ virCapabilitiesGetCpusForNode(virCapsPtr caps,
                               size_t node,
                               virBitmapPtr cpumask)
 {
-    virCapsHostNUMACellPtr cell = caps->host.numaCell[node];
+    virCapsHostNUMACellPtr cell = NULL;
     size_t cpu;
+    size_t index;
+    /* The numa node numbers can be non-contiguous. Ex: 0,1,16,17. */
+    for (index = 0; index < caps->host.nnumaCell; index++) {
+        if (caps->host.numaCell[index]->num == node) {
+            cell = caps->host.numaCell[index];
+            break;
+        }
+    }
 
-    for (cpu = 0; cpu < cell->ncpus; cpu++) {
+    for (cpu = 0; cell && cpu < cell->ncpus; cpu++) {
         if (virBitmapSetBit(cpumask, cell->cpus[cpu].id) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Cpu '%u' in node '%zu' is out of range "
index 94844df9d10217956f2935f398fda1ed29ca415c..59e018de80a52828017b299b7ab139998db494c6 100644 (file)
@@ -8566,12 +8566,13 @@ qemuDomainSetNumaParamsLive(virDomainObjPtr vm,
 
     for (i = 0; i < caps->host.nnumaCell; i++) {
         bool result;
-        if (virBitmapGetBit(nodeset, i, &result) < 0) {
+        virCapsHostNUMACellPtr cell = caps->host.numaCell[i];
+        if (virBitmapGetBit(nodeset, cell->num, &result) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Failed to get cpuset bit values"));
             goto cleanup;
         }
-        if (result && (virBitmapSetBit(temp_nodeset, i) < 0)) {
+        if (result && (virBitmapSetBit(temp_nodeset, cell->num) < 0)) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Failed to set temporary cpuset bit values"));
             goto cleanup;
index c1f60cd99c4c6ea1f805c713b216e46a4a442516..33d2a776f4ac2667f88268128a35d0a1e1adab3b 100644 (file)
@@ -2002,7 +2002,7 @@ qemuPrepareCpumap(virQEMUDriverPtr driver,
             size_t j;
             int cur_ncpus = caps->host.numaCell[i]->ncpus;
             bool result;
-            if (virBitmapGetBit(nodemask, i, &result) < 0) {
+            if (virBitmapGetBit(nodemask, caps->host.numaCell[i]->num, &result) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("Failed to convert nodeset to cpuset"));
                 virBitmapFree(cpumap);