]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainNumaFillCPUsInNode: Skip over NUMA nodes without vCPUs
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 30 Sep 2020 08:37:29 +0000 (10:37 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Oct 2020 08:36:17 +0000 (10:36 +0200)
After v6.5.0-rc1~148 we started to rectify vCPU to guest NUMA
assignment - if there is a vCPU not assigned to any guest NUMA
node it is automatically assigned to node #0.

A month later I've made it possible to define guest NUMA nodes
without vCPUs (v6.6.0-rc1~250) - this is needed because of HMAT.
As a part of that I fixed all callers of
virDomainNumaGetNodeCpumask() (which returns a bitmap of vCPUs for
given node) to handle case when NULL is returned (i.e. no vCPUs
assigned to given node). But of course my patch was written
before aforementioned vCPU rectify patch but merged afterwards
and hence I missed the virDomainNumaFillCPUsInNode() caller.

And because we are dealing with a NULL pointer, of course this
leads to a crash. Just try to define a domain with at least two
NUMA nodes and no vCPU assignment to any of the nodes.

Fixes: a26f61ee0cffa421b87ef568002b684dd8025432
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1880289
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/conf/numa_conf.c

index bfa312215c2f9d07103aa291776fa7cd922062e3..cc6c77f105623b9862cc2fd8b82cf505a4d4983c 100644 (file)
@@ -1816,7 +1816,7 @@ virDomainNumaFillCPUsInNode(virDomainNumaPtr numa,
     for (i = 0; i < numa->nmem_nodes; i++) {
         virBitmapPtr nodeCpus = virDomainNumaGetNodeCpumask(numa, i);
 
-        if (i == node)
+        if (i == node || !nodeCpus)
             continue;
 
         virBitmapSubtract(maxCPUsBitmap, nodeCpus);