[libvirt] [PATCH] nodeinfo: fix build on non-Linux

Eric Blake eblake at redhat.com
Thu Nov 7 00:23:48 UTC 2013


Commit b0f8546 broke the build on mingw, by exposing code that
had Linux-specific dependencies but which was previously protected
by libnuma ifdef guards:

make[3]: Entering directory `/home/eblake/libvirt-tmp/build/src'
  CC       libvirt_driver_la-nodeinfo.lo
../../src/nodeinfo.c: In function 'virNodeGetSiblingsList':
../../src/nodeinfo.c:1543:30: error: 'SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX' undeclared (first use in this function)
     if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0)
                              ^
../../src/nodeinfo.c:1543:30: note: each undeclared identifier is reported only once for each function it appears in
../../src/nodeinfo.c: In function 'virNodeCapsFillCPUInfo':
../../src/nodeinfo.c:1562:5: error: implicit declaration of function 'virNodeGetCpuValue' [-Werror=implicit-function-declaration]
     if ((tmp = virNodeGetCpuValue(SYSFS_CPU_PATH, cpu_id,
     ^
../../src/nodeinfo.c:1562:5: error: nested extern declaration of 'virNodeGetCpuValue' [-Werror=nested-externs]
../../src/nodeinfo.c:1562:35: error: 'SYSFS_CPU_PATH' undeclared (first use in this function)
     if ((tmp = virNodeGetCpuValue(SYSFS_CPU_PATH, cpu_id,
                                   ^
cc1: all warnings being treated as errors

* src/nodeinfo.c (virNodeCapsFillCPUInfo): Make conditional.
(virNodeGetSiblingsList): Move into #ifdef linux block.

Signed-off-by: Eric Blake <eblake at redhat.com>
---

Pushing under the build-breaker rule.

 src/nodeinfo.c | 56 ++++++++++++++++++++++++++++++++------------------------
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 6c1fcc7..1838547 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -867,6 +867,30 @@ error:
     virBitmapFree(map);
     return NULL;
 }
+
+
+static virBitmapPtr
+virNodeGetSiblingsList(const char *dir, int cpu_id)
+{
+    char *path = NULL;
+    char *buf = NULL;
+    virBitmapPtr ret = NULL;
+
+    if (virAsprintf(&path, "%s/cpu%u/topology/thread_siblings_list",
+                    dir, cpu_id) < 0)
+        goto cleanup;
+
+    if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0)
+        goto cleanup;
+
+    if (virBitmapParse(buf, 0, &ret, virNumaGetMaxCPUs()) < 0)
+        goto cleanup;
+
+cleanup:
+    VIR_FREE(buf);
+    VIR_FREE(path);
+    return ret;
+}
 #endif

 int nodeGetInfo(virNodeInfoPtr nodeinfo)
@@ -1529,33 +1553,12 @@ nodeGetFreeMemoryFake(void)
     return ret;
 }

-static virBitmapPtr
-virNodeGetSiblingsList(const char *dir, int cpu_id)
-{
-    char *path = NULL;
-    char *buf = NULL;
-    virBitmapPtr ret = NULL;
-
-    if (virAsprintf(&path, "%s/cpu%u/topology/thread_siblings_list",
-                    dir, cpu_id) < 0)
-        goto cleanup;
-
-    if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0)
-        goto cleanup;
-
-    if (virBitmapParse(buf, 0, &ret, virNumaGetMaxCPUs()) < 0)
-        goto cleanup;
-
-cleanup:
-    VIR_FREE(buf);
-    VIR_FREE(path);
-    return ret;
-}
-
 /* returns 1 on success, 0 if the detection failed and -1 on hard error */
 static int
-virNodeCapsFillCPUInfo(int cpu_id, virCapsHostNUMACellCPUPtr cpu)
+virNodeCapsFillCPUInfo(int cpu_id ATTRIBUTE_UNUSED,
+                       virCapsHostNUMACellCPUPtr cpu ATTRIBUTE_UNUSED)
 {
+#ifdef __linux__
     int tmp;
     cpu->id = cpu_id;

@@ -1575,6 +1578,11 @@ virNodeCapsFillCPUInfo(int cpu_id, virCapsHostNUMACellCPUPtr cpu)
         return -1;

     return 0;
+#else
+    virReportError(VIR_ERR_NO_SUPPORT, "%s",
+                   _("node cpu info not implemented on this platform"));
+    return -1;
+#endif
 }

 int
-- 
1.8.3.1




More information about the libvir-list mailing list