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

[libvirt] [PATCH 2/2] Fix build with clang



Even though this is, technically speaking, a build-breaker fix,
different version of this was posted before [1] and not accepted
(although neither rejected), so I'm sending this as another way
of approaching it.

[1] https://www.redhat.com/archives/libvir-list/2015-March/msg00203.html

Signed-off-by: Martin Kletzander <mkletzan redhat com>
---
 tests/qemuxml2argvmock.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 8426108b29ed..5667f34f1267 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -62,6 +62,34 @@ virNumaNodeIsAvailable(int node)
 {
     return node >= 0 && node <= virNumaGetMaxNode();
 }
+
+/* This is a copy-paste of the same function from src/util/virnuma.c.
+ * the reason for this is that some compilers might inline the
+ * function above (virNumaNodeIsAvailable) and hence mocking that
+ * function is pointless from our test suite's POV.  This is a
+ * (hopefully) temporary workaround until someone finds out how to
+ * disable inlining of exported functions with -O2 on clang.  The
+ * other option would be disabling inlining of that particular
+ * function which was proposed but did not come to a conclusion.
+ */
+bool
+virNumaNodesetIsAvailable(virBitmapPtr nodeset)
+{
+    ssize_t bit = -1;
+
+    if (!nodeset)
+        return true;
+
+    while ((bit = virBitmapNextSetBit(nodeset, bit)) >= 0) {
+        if (virNumaNodeIsAvailable(bit))
+            continue;
+
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("NUMA node %zd is unavailable"), bit);
+        return false;
+    }
+    return true;
+}
 #endif /* WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET */

 char *
-- 
2.7.3


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