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

[libvirt] [PATCH] qemuxml2argvtest: uncoditionally mock NUMA routines



Currently, qemuxml2argvmock.c only mocks virNumaNodeIsAvailable(), and
only if libvirt was built with NUMA support. This causes some test
failures where NUMA is involved.

For example, memory-hotplug-dimm fails because it goes all they way down
to qemuBuildMemoryBackendStr() that calls virNumaNodesetIsAvailable()
for a user specified nodeset and fails, hence the test (unexpectedly)
fails.

To make qemuxml2argtest successfully run on non-NUMA platforms, do the
following:

 - mock virNumaNodeIsAvailable() unconditionally
 - add a mock for virNumaNodesetIsAvailable()
---
 tests/qemuxml2argvmock.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 1616eed..57e56ab 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -56,17 +56,28 @@ virNumaGetMaxNode(void)
    return maxnodesNum;
 }
 
-#if WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET
-/*
- * In case libvirt is compiled with full NUMA support, we need to mock
- * this function in order to fake what numa nodes are available.
- */
 bool
 virNumaNodeIsAvailable(int node)
 {
     return node >= 0 && node <= virNumaGetMaxNode();
 }
-#endif /* WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET */
+
+bool
+virNumaNodesetIsAvailable(virBitmapPtr nodeset ATTRIBUTE_UNUSED)
+{
+    ssize_t bit = -1;
+
+    if (!nodeset)
+        return true;
+
+    while ((bit = virBitmapNextSetBit(nodeset, bit)) >= 0) {
+        if (virNumaNodeIsAvailable(bit))
+            continue;
+
+        return false;
+    }
+    return true;
+}
 
 char *
 virTPMCreateCancelPath(const char *devpath)
-- 
2.7.4


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