[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] virnuma: Report error when NUMA -> CPUs translation fails



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>
---
 src/util/virnuma.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index ba1e4363d6..2872ce3c5e 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -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;
-- 
2.26.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]