[libvirt] [PATCH v3 8/9] tests: Extend NUMA mocking

Andrea Bolognani posted 9 patches 7 years ago
[libvirt] [PATCH v3 8/9] tests: Extend NUMA mocking
Posted by Andrea Bolognani 7 years ago
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>
---
 tests/qemuxml2argvmock.c | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index adab5c9111..6d78063f00 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -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)
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 8/9] tests: Extend NUMA mocking
Posted by Daniel P. Berrangé 7 years ago
On Thu, May 03, 2018 at 12:54:22PM +0200, Andrea Bolognani wrote:
> 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>
> ---
>  tests/qemuxml2argvmock.c | 38 +++++++++++++++++++++++++++++---------
>  1 file changed, 29 insertions(+), 9 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list