mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
numa: Introduce virNumaIsAvailable and use it instead of numa_available
All functions from libnuma must be protected with ifdefs. Avoid this by using our own wrapper.
This commit is contained in:
parent
a4a7c7e9c4
commit
f8ee8fe3f9
@ -1523,6 +1523,7 @@ virNodeSuspendGetTargetMask;
|
||||
virDomainNumatuneMemModeTypeFromString;
|
||||
virDomainNumatuneMemModeTypeToString;
|
||||
virNumaGetAutoPlacementAdvice;
|
||||
virNumaIsAvailable;
|
||||
virNumaSetupMemoryPolicy;
|
||||
virNumaTuneMemPlacementModeTypeFromString;
|
||||
virNumaTuneMemPlacementModeTypeToString;
|
||||
|
@ -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();
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -55,4 +55,6 @@ char *virNumaGetAutoPlacementAdvice(unsigned short vcups,
|
||||
|
||||
int virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
|
||||
virBitmapPtr nodemask);
|
||||
|
||||
bool virNumaIsAvailable(void);
|
||||
#endif /* __VIR_NUMA_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user