]> xenbits.xensource.com Git - libvirt.git/commitdiff
numa: Introduce virNumaIsAvailable and use it instead of numa_available
authorPeter Krempa <pkrempa@redhat.com>
Thu, 17 Oct 2013 14:57:29 +0000 (16:57 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 4 Nov 2013 09:48:00 +0000 (10:48 +0100)
All functions from libnuma must be protected with ifdefs. Avoid this by
using our own wrapper.

src/libvirt_private.syms
src/nodeinfo.c
src/util/virnuma.c
src/util/virnuma.h

index 675835f040a5ac72b100e4f52cb3148d236680fb..786d3eda745a119b4a1242393d473e22d0e1acc2 100644 (file)
@@ -1523,6 +1523,7 @@ virNodeSuspendGetTargetMask;
 virDomainNumatuneMemModeTypeFromString;
 virDomainNumatuneMemModeTypeToString;
 virNumaGetAutoPlacementAdvice;
+virNumaIsAvailable;
 virNumaSetupMemoryPolicy;
 virNumaTuneMemPlacementModeTypeFromString;
 virNumaTuneMemPlacementModeTypeToString;
index a0fdfe7d63a16b5471f03ddea11bcf1d638318fe..8d926302f72e95eea06384ec8f922b07f4f1a99f 100644 (file)
@@ -55,6 +55,7 @@
 #include "virfile.h"
 #include "virtypedparam.h"
 #include "virstring.h"
+#include "virnuma.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -999,15 +1000,11 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
             if (VIR_STRDUP(meminfo_path, MEMINFO_PATH) < 0)
                 return -1;
         } else {
-# if WITH_NUMACTL
-            if (numa_available() < 0) {
-# endif
+            if (!virNumaIsAvailable()) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                "%s", _("NUMA not supported on this host"));
                 return -1;
-# if WITH_NUMACTL
             }
-# endif
 
 # if WITH_NUMACTL
             if (cellNum > numa_max_node()) {
@@ -1622,7 +1619,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
     int ncpus = 0;
     bool topology_failed = false;
 
-    if (numa_available() < 0)
+    if (!virNumaIsAvailable())
         return nodeCapsInitNUMAFake(caps);
 
     int mask_n_bytes = max_n_cpus / 8;
@@ -1694,7 +1691,7 @@ nodeGetCellsFreeMemory(unsigned long long *freeMems,
     int ret = -1;
     int maxCell;
 
-    if (numa_available() < 0)
+    if (!virNumaIsAvailable())
         return nodeGetCellsFreeMemoryFake(freeMems,
                                           startCell, maxCells);
 
@@ -1728,7 +1725,7 @@ nodeGetFreeMemory(void)
     unsigned long long freeMem = 0;
     int n;
 
-    if (numa_available() < 0)
+    if (!virNumaIsAvailable())
         return nodeGetFreeMemoryFake();
 
 
index ecf7ede954074caf7bec690f08974241b140edef..11078a1e65bc3f14b774f002db20a0693c81f7e4 100644 (file)
@@ -167,6 +167,13 @@ virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
 cleanup:
     return ret;
 }
+
+
+bool
+virNumaIsAvailable(void)
+{
+    return numa_available() != -1;
+}
 #else
 int
 virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
@@ -181,4 +188,11 @@ virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
 
     return 0;
 }
+
+
+bool
+virNumaIsAvailable(void)
+{
+    return false;
+}
 #endif
index 9ff8e692ef0ffbd3e168e34d5480a3fcf5583d8a..5f9c38bf6ba53b07076bc138d068726f1b0b9334 100644 (file)
@@ -55,4 +55,6 @@ char *virNumaGetAutoPlacementAdvice(unsigned short vcups,
 
 int virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
                              virBitmapPtr nodemask);
+
+bool virNumaIsAvailable(void);
 #endif /* __VIR_NUMA_H__ */