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>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Michal Privoznik 2020-09-07 17:02:08 +02:00
parent caa9560c15
commit 9e0d4b9240

View 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;