]> xenbits.xensource.com Git - libvirt.git/commitdiff
numa: Replace NUMA_MAX_N_CPUS macro with virNumaGetMaxCPUs()
authorPeter Krempa <pkrempa@redhat.com>
Fri, 18 Oct 2013 12:43:34 +0000 (14:43 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 4 Nov 2013 09:50:20 +0000 (10:50 +0100)
src/nodeinfo.c
src/util/virnuma.c
src/util/virnuma.h

index 6e8593b4c4087416e1c9594d9afaea1c5e443123..1482036a339eaf8005977ba944f98a153423afcf 100644 (file)
@@ -1535,11 +1535,6 @@ nodeGetFreeMemoryFake(void)
 }
 
 #if WITH_NUMACTL
-# if LIBNUMA_API_VERSION <= 1
-#  define NUMA_MAX_N_CPUS 4096
-# else
-#  define NUMA_MAX_N_CPUS (numa_all_cpus_ptr->size)
-# endif
 
 # define n_bits(var) (8 * sizeof(var))
 # define MASK_CPU_ISSET(mask, cpu) \
@@ -1559,7 +1554,7 @@ virNodeGetSiblingsList(const char *dir, int cpu_id)
     if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0)
         goto cleanup;
 
-    if (virBitmapParse(buf, 0, &ret, NUMA_MAX_N_CPUS) < 0)
+    if (virBitmapParse(buf, 0, &ret, virNumaGetMaxCPUs()) < 0)
         goto cleanup;
 
 cleanup:
@@ -1602,7 +1597,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
     unsigned long long memory;
     virCapsHostNUMACellCPUPtr cpus = NULL;
     int ret = -1;
-    int max_n_cpus = NUMA_MAX_N_CPUS;
+    int max_n_cpus = virNumaGetMaxCPUs();
     int mask_n_bytes = max_n_cpus / 8;
     int ncpus = 0;
     bool topology_failed = false;
index 15a18e9f55a517ffd1e474345c63f13699101b9d..0530d64f58fcc0a01bbafb3a3a1ffee71fffbd92 100644 (file)
 
 #include <config.h>
 
+#define NUMA_MAX_N_CPUS 4096
+
 #if WITH_NUMACTL
 # define NUMA_VERSION1_COMPATIBILITY 1
 # include <numa.h>
-#endif
+
+# if LIBNUMA_API_VERSION > 1
+#  undef NUMA_MAX_N_CPUS
+#  define NUMA_MAX_N_CPUS (numa_all_cpus_ptr->size)
+# endif
+
+#endif /* WITH_NUMACTL */
 
 #include "virnuma.h"
 #include "vircommand.h"
@@ -288,3 +296,17 @@ virNumaGetNodeMemory(int node ATTRIBUTE_UNUSED,
     return -1;
 }
 #endif
+
+
+/**
+ * virNumaGetMaxCPUs:
+ *
+ * Get the maximum count of CPUs supportable in the host.
+ *
+ * Returns the count of CPUs supported.
+ */
+unsigned int
+virNumaGetMaxCPUs(void)
+{
+    return NUMA_MAX_N_CPUS;
+}
index 7640d1bfed26af2a459de0933de1a117c63b25d1..62b2c0ad9c6692b260b313107d6c2ac09f92e306 100644 (file)
@@ -62,4 +62,6 @@ int virNumaGetNodeMemory(int node,
                          unsigned long long *memsize,
                          unsigned long long *memfree);
 
+unsigned int virNumaGetMaxCPUs(void);
+
 #endif /* __VIR_NUMA_H__ */