From 9e0d4b9240143bc6863a58d62b7e8e83a28f95fe Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 7 Sep 2020 17:02:08 +0200 Subject: [PATCH] virnuma: Report error when NUMA -> CPUs translation fails When starting a domain with 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 Reviewed-by: Martin Kletzander --- 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;