]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnumamock: Allow CPU-less NUMA nodes
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 17 May 2021 10:40:00 +0000 (12:40 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 17 May 2021 13:54:20 +0000 (15:54 +0200)
The original virNumaGetNodeCPUs() returns an empty virBitmap if
given NUMA node has no CPUs. But that's not how our mock behaves
- it looks under $fakesysfs/node/node$N/cpulist only to find an
empty file which is then passed to virBitmapParseUnlimited()
which threats such input as error.

Fortunately, we don't have any fake sysfs data where this path is
hit, but we might soon.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/virnumamock.c

index 3a203ded77d0d2c5bca31973b6d39b4c448ca403..ff9c6e951d456074c14a8cafbab7b22d10cdf287 100644 (file)
@@ -172,7 +172,12 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus)
                                SYSFS_SYSTEM_PATH, node) < 0)
         return -1;
 
-    *cpus = virBitmapParseUnlimited(cpulist);
+    if (STREQ(cpulist, "")) {
+        unsigned int max_n_cpus = virNumaGetMaxCPUs();
+        *cpus = virBitmapNew(max_n_cpus);
+    } else {
+        *cpus = virBitmapParseUnlimited(cpulist);
+    }
     if (!*cpus)
         goto cleanup;