]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virnuma: Report error when NUMA -> CPUs translation fails
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 7 Sep 2020 15:02:08 +0000 (17:02 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 8 Sep 2020 09:00:54 +0000 (11:00 +0200)
When starting a domain with <numatune/> set libvirt translates
given NUMA nodes into a set of host CPUs which is then used to
QEMU process affinity. But, if the numatune contains a
non-existent NUMA node then the translation fails with no error
reported. This is because virNumaNodesetToCPUset() calls
virNumaGetNodeCPUs() and expects it to report an error on
failure. Well, it does except for non-existent NUMA nodes. While
this behaviour might look strange it is actually desired because
of how we construct host capabilities. The virNumaGetNodeCPUs()
is called from virCapabilitiesHostNUMAInitReal() where we do not
want any error reported for non-existent NUMA nodes.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1724866
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virnuma.c

index ba1e4363d6c000dffed1dd3dff8343aac8a06784..2872ce3c5ee95085343b30b95af9319f6c968755 100644 (file)
@@ -316,12 +316,21 @@ virNumaNodesetToCPUset(virBitmapPtr nodeset,
 
     for (i = 0; i < nodesetSize; i++) {
         g_autoptr(virBitmap) nodeCPUs = NULL;
+        int rc;
 
         if (!virBitmapIsBitSet(nodeset, i))
             continue;
 
-        if (virNumaGetNodeCPUs(i, &nodeCPUs) < 0)
+        rc = virNumaGetNodeCPUs(i, &nodeCPUs);
+        if (rc < 0) {
+            /* Error is reported for cases other than non-existent NUMA node. */
+            if (rc == -2) {
+                virReportError(VIR_ERR_OPERATION_FAILED,
+                               _("NUMA node %zu is not available"),
+                               i);
+            }
             return -1;
+        }
 
         if (virBitmapUnion(allNodesCPUs, nodeCPUs) < 0)
             return -1;