]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Extend NUMA mocking
authorAndrea Bolognani <abologna@redhat.com>
Wed, 2 May 2018 15:35:21 +0000 (17:35 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 3 May 2018 16:23:30 +0000 (18:23 +0200)
While the current amount of mocking works just fine on most of
our target platforms, it somehow causes issues when using Clang
on FreeBSD.

Work around the issue by mocking a couple more functions. It's
not pretty, but it makes qemuxml2argvtest pass on FreeBSD at
long last.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/qemuxml2argvmock.c

index adab5c91117fd5cbf4a653f6b3f73f6558fe6fa0..6d78063f009c3459a1823305f2120a3aae950f6b 100644 (file)
@@ -55,25 +55,45 @@ time_t time(time_t *t)
     return ret;
 }
 
+bool
+virNumaIsAvailable(void)
+{
+    return true;
+}
+
 int
 virNumaGetMaxNode(void)
 {
-   const int maxnodesNum = 7;
-
-   return maxnodesNum;
+   return 7;
 }
 
-#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.
- */
+/* We shouldn't need to mock virNumaNodeIsAvailable() and *definitely* not
+ * virNumaNodesetIsAvailable(), but it seems to be the only way to get
+ * mocking to work with Clang on FreeBSD, so keep these duplicates around
+ * until we figure out a cleaner solution */
 bool
 virNumaNodeIsAvailable(int node)
 {
     return node >= 0 && node <= virNumaGetMaxNode();
 }
-#endif /* WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET */
+
+bool
+virNumaNodesetIsAvailable(virBitmapPtr nodeset)
+{
+    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)