mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +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;
|
virDomainNumatuneMemModeTypeFromString;
|
||||||
virDomainNumatuneMemModeTypeToString;
|
virDomainNumatuneMemModeTypeToString;
|
||||||
virNumaGetAutoPlacementAdvice;
|
virNumaGetAutoPlacementAdvice;
|
||||||
|
virNumaIsAvailable;
|
||||||
virNumaSetupMemoryPolicy;
|
virNumaSetupMemoryPolicy;
|
||||||
virNumaTuneMemPlacementModeTypeFromString;
|
virNumaTuneMemPlacementModeTypeFromString;
|
||||||
virNumaTuneMemPlacementModeTypeToString;
|
virNumaTuneMemPlacementModeTypeToString;
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
#include "virtypedparam.h"
|
#include "virtypedparam.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
|
#include "virnuma.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#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)
|
if (VIR_STRDUP(meminfo_path, MEMINFO_PATH) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
# if WITH_NUMACTL
|
if (!virNumaIsAvailable()) {
|
||||||
if (numa_available() < 0) {
|
|
||||||
# endif
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("NUMA not supported on this host"));
|
"%s", _("NUMA not supported on this host"));
|
||||||
return -1;
|
return -1;
|
||||||
# if WITH_NUMACTL
|
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
|
|
||||||
# if WITH_NUMACTL
|
# if WITH_NUMACTL
|
||||||
if (cellNum > numa_max_node()) {
|
if (cellNum > numa_max_node()) {
|
||||||
@ -1622,7 +1619,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
|
|||||||
int ncpus = 0;
|
int ncpus = 0;
|
||||||
bool topology_failed = false;
|
bool topology_failed = false;
|
||||||
|
|
||||||
if (numa_available() < 0)
|
if (!virNumaIsAvailable())
|
||||||
return nodeCapsInitNUMAFake(caps);
|
return nodeCapsInitNUMAFake(caps);
|
||||||
|
|
||||||
int mask_n_bytes = max_n_cpus / 8;
|
int mask_n_bytes = max_n_cpus / 8;
|
||||||
@ -1694,7 +1691,7 @@ nodeGetCellsFreeMemory(unsigned long long *freeMems,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
int maxCell;
|
int maxCell;
|
||||||
|
|
||||||
if (numa_available() < 0)
|
if (!virNumaIsAvailable())
|
||||||
return nodeGetCellsFreeMemoryFake(freeMems,
|
return nodeGetCellsFreeMemoryFake(freeMems,
|
||||||
startCell, maxCells);
|
startCell, maxCells);
|
||||||
|
|
||||||
@ -1728,7 +1725,7 @@ nodeGetFreeMemory(void)
|
|||||||
unsigned long long freeMem = 0;
|
unsigned long long freeMem = 0;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (numa_available() < 0)
|
if (!virNumaIsAvailable())
|
||||||
return nodeGetFreeMemoryFake();
|
return nodeGetFreeMemoryFake();
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,6 +167,13 @@ virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
|
|||||||
cleanup:
|
cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
virNumaIsAvailable(void)
|
||||||
|
{
|
||||||
|
return numa_available() != -1;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
|
virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
|
||||||
@ -181,4 +188,11 @@ virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
virNumaIsAvailable(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,4 +55,6 @@ char *virNumaGetAutoPlacementAdvice(unsigned short vcups,
|
|||||||
|
|
||||||
int virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
|
int virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
|
||||||
virBitmapPtr nodemask);
|
virBitmapPtr nodemask);
|
||||||
|
|
||||||
|
bool virNumaIsAvailable(void);
|
||||||
#endif /* __VIR_NUMA_H__ */
|
#endif /* __VIR_NUMA_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user