mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
nodeinfo: Add sysfs_prefix to nodeCapsInitNUMA
Add the sysfs_prefix argument to the call to allow for setting the path for tests to something other than SYSFS_CPU_PATH which is a derivative of SYSFS_SYSTEM_PATH Use cpupath for nodeCapsInitNUMAFake and remove SYSFS_CPU_PATH
This commit is contained in:
parent
29e4f2243f
commit
b97b30480d
@ -77,7 +77,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
|
|||||||
* unexpected failures. We don't want to break the lxc
|
* unexpected failures. We don't want to break the lxc
|
||||||
* driver in this scenario, so log errors & carry on
|
* driver in this scenario, so log errors & carry on
|
||||||
*/
|
*/
|
||||||
if (nodeCapsInitNUMA(caps) < 0) {
|
if (nodeCapsInitNUMA(NULL, caps) < 0) {
|
||||||
virCapabilitiesFreeNUMAInfo(caps);
|
virCapabilitiesFreeNUMAInfo(caps);
|
||||||
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
|
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,6 @@ freebsdNodeGetMemoryStats(virNodeMemoryStatsPtr params,
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
# define CPUINFO_PATH "/proc/cpuinfo"
|
# define CPUINFO_PATH "/proc/cpuinfo"
|
||||||
# define SYSFS_SYSTEM_PATH "/sys/devices/system"
|
# define SYSFS_SYSTEM_PATH "/sys/devices/system"
|
||||||
# define SYSFS_CPU_PATH SYSFS_SYSTEM_PATH"/cpu"
|
|
||||||
# define PROCSTAT_PATH "/proc/stat"
|
# define PROCSTAT_PATH "/proc/stat"
|
||||||
# define MEMINFO_PATH "/proc/meminfo"
|
# define MEMINFO_PATH "/proc/meminfo"
|
||||||
# define SYSFS_MEMORY_SHARED_PATH "/sys/kernel/mm/ksm"
|
# define SYSFS_MEMORY_SHARED_PATH "/sys/kernel/mm/ksm"
|
||||||
@ -1660,7 +1659,9 @@ nodeGetCPUMap(const char *sysfs_prefix,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
|
nodeCapsInitNUMAFake(const char *prefix,
|
||||||
|
const char *cpupath ATTRIBUTE_UNUSED,
|
||||||
|
virCapsPtr caps ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virNodeInfo nodeinfo;
|
virNodeInfo nodeinfo;
|
||||||
virCapsHostNUMACellCPUPtr cpus;
|
virCapsHostNUMACellCPUPtr cpus;
|
||||||
@ -1669,7 +1670,7 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
|
|||||||
int id, cid;
|
int id, cid;
|
||||||
int onlinecpus ATTRIBUTE_UNUSED;
|
int onlinecpus ATTRIBUTE_UNUSED;
|
||||||
|
|
||||||
if (nodeGetInfo(NULL, &nodeinfo) < 0)
|
if (nodeGetInfo(prefix, &nodeinfo) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
|
ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
|
||||||
@ -1683,7 +1684,7 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
|
|||||||
for (c = 0; c < nodeinfo.cores; c++) {
|
for (c = 0; c < nodeinfo.cores; c++) {
|
||||||
for (t = 0; t < nodeinfo.threads; t++) {
|
for (t = 0; t < nodeinfo.threads; t++) {
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
if (virNodeGetCpuValue(SYSFS_CPU_PATH, id, "online", 1)) {
|
if (virNodeGetCpuValue(cpupath, id, "online", 1)) {
|
||||||
#endif
|
#endif
|
||||||
cpus[cid].id = id;
|
cpus[cid].id = id;
|
||||||
cpus[cid].socket_id = s;
|
cpus[cid].socket_id = s;
|
||||||
@ -1810,26 +1811,27 @@ nodeGetMemoryFake(unsigned long long *mem,
|
|||||||
|
|
||||||
/* returns 1 on success, 0 if the detection failed and -1 on hard error */
|
/* returns 1 on success, 0 if the detection failed and -1 on hard error */
|
||||||
static int
|
static int
|
||||||
virNodeCapsFillCPUInfo(int cpu_id ATTRIBUTE_UNUSED,
|
virNodeCapsFillCPUInfo(const char *cpupath ATTRIBUTE_UNUSED,
|
||||||
|
int cpu_id ATTRIBUTE_UNUSED,
|
||||||
virCapsHostNUMACellCPUPtr cpu ATTRIBUTE_UNUSED)
|
virCapsHostNUMACellCPUPtr cpu ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
int tmp;
|
int tmp;
|
||||||
cpu->id = cpu_id;
|
cpu->id = cpu_id;
|
||||||
|
|
||||||
if ((tmp = virNodeGetCpuValue(SYSFS_CPU_PATH, cpu_id,
|
if ((tmp = virNodeGetCpuValue(cpupath, cpu_id,
|
||||||
"topology/physical_package_id", -1)) < 0)
|
"topology/physical_package_id", -1)) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cpu->socket_id = tmp;
|
cpu->socket_id = tmp;
|
||||||
|
|
||||||
if ((tmp = virNodeGetCpuValue(SYSFS_CPU_PATH, cpu_id,
|
if ((tmp = virNodeGetCpuValue(cpupath, cpu_id,
|
||||||
"topology/core_id", -1)) < 0)
|
"topology/core_id", -1)) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cpu->core_id = tmp;
|
cpu->core_id = tmp;
|
||||||
|
|
||||||
if (!(cpu->siblings = virNodeGetSiblingsList(SYSFS_CPU_PATH, cpu_id)))
|
if (!(cpu->siblings = virNodeGetSiblingsList(cpupath, cpu_id)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1917,8 +1919,11 @@ virNodeCapsGetPagesInfo(int node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeCapsInitNUMA(virCapsPtr caps)
|
nodeCapsInitNUMA(const char *sysfs_prefix,
|
||||||
|
virCapsPtr caps)
|
||||||
{
|
{
|
||||||
|
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
|
||||||
|
char *cpupath;
|
||||||
int n;
|
int n;
|
||||||
unsigned long long memory;
|
unsigned long long memory;
|
||||||
virCapsHostNUMACellCPUPtr cpus = NULL;
|
virCapsHostNUMACellCPUPtr cpus = NULL;
|
||||||
@ -1933,8 +1938,13 @@ nodeCapsInitNUMA(virCapsPtr caps)
|
|||||||
bool topology_failed = false;
|
bool topology_failed = false;
|
||||||
int max_node;
|
int max_node;
|
||||||
|
|
||||||
if (!virNumaIsAvailable())
|
if (virAsprintf(&cpupath, "%s/cpu", prefix) < 0)
|
||||||
return nodeCapsInitNUMAFake(caps);
|
return -1;
|
||||||
|
|
||||||
|
if (!virNumaIsAvailable()) {
|
||||||
|
ret = nodeCapsInitNUMAFake(prefix, cpupath, caps);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if ((max_node = virNumaGetMaxNode()) < 0)
|
if ((max_node = virNumaGetMaxNode()) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1955,7 +1965,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
|
|||||||
|
|
||||||
for (i = 0; i < virBitmapSize(cpumap); i++) {
|
for (i = 0; i < virBitmapSize(cpumap); i++) {
|
||||||
if (virBitmapIsBitSet(cpumap, i)) {
|
if (virBitmapIsBitSet(cpumap, i)) {
|
||||||
if (virNodeCapsFillCPUInfo(i, cpus + cpu++) < 0) {
|
if (virNodeCapsFillCPUInfo(cpupath, i, cpus + cpu++) < 0) {
|
||||||
topology_failed = true;
|
topology_failed = true;
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
}
|
}
|
||||||
@ -1995,6 +2005,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
|
|||||||
VIR_FREE(cpus);
|
VIR_FREE(cpus);
|
||||||
VIR_FREE(siblings);
|
VIR_FREE(siblings);
|
||||||
VIR_FREE(pageinfo);
|
VIR_FREE(pageinfo);
|
||||||
|
VIR_FREE(cpupath);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# include "capabilities.h"
|
# include "capabilities.h"
|
||||||
|
|
||||||
int nodeGetInfo(const char *sysfs_prefix, virNodeInfoPtr nodeinfo);
|
int nodeGetInfo(const char *sysfs_prefix, virNodeInfoPtr nodeinfo);
|
||||||
int nodeCapsInitNUMA(virCapsPtr caps);
|
int nodeCapsInitNUMA(const char *sysfs_prefix, virCapsPtr caps);
|
||||||
|
|
||||||
int nodeGetCPUStats(int cpuNum,
|
int nodeGetCPUStats(int cpuNum,
|
||||||
virNodeCPUStatsPtr params,
|
virNodeCPUStatsPtr params,
|
||||||
|
@ -175,7 +175,7 @@ virCapsPtr openvzCapsInit(void)
|
|||||||
false, false)) == NULL)
|
false, false)) == NULL)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (nodeCapsInitNUMA(caps) < 0)
|
if (nodeCapsInitNUMA(NULL, caps) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if ((guest = virCapabilitiesAddGuest(caps,
|
if ((guest = virCapabilitiesAddGuest(caps,
|
||||||
|
@ -335,7 +335,7 @@ phypCapsInit(void)
|
|||||||
* unexpected failures. We don't want to break the QEMU
|
* unexpected failures. We don't want to break the QEMU
|
||||||
* driver in this scenario, so log errors & carry on
|
* driver in this scenario, so log errors & carry on
|
||||||
*/
|
*/
|
||||||
if (nodeCapsInitNUMA(caps) < 0) {
|
if (nodeCapsInitNUMA(NULL, caps) < 0) {
|
||||||
virCapabilitiesFreeNUMAInfo(caps);
|
virCapabilitiesFreeNUMAInfo(caps);
|
||||||
VIR_WARN
|
VIR_WARN
|
||||||
("Failed to query host NUMA topology, disabling NUMA capabilities");
|
("Failed to query host NUMA topology, disabling NUMA capabilities");
|
||||||
|
@ -1024,7 +1024,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
|
|||||||
* unexpected failures. We don't want to break the QEMU
|
* unexpected failures. We don't want to break the QEMU
|
||||||
* driver in this scenario, so log errors & carry on
|
* driver in this scenario, so log errors & carry on
|
||||||
*/
|
*/
|
||||||
if (nodeCapsInitNUMA(caps) < 0) {
|
if (nodeCapsInitNUMA(NULL, caps) < 0) {
|
||||||
virCapabilitiesFreeNUMAInfo(caps);
|
virCapabilitiesFreeNUMAInfo(caps);
|
||||||
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
|
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ virCapsPtr umlCapsInit(void)
|
|||||||
* unexpected failures. We don't want to break the QEMU
|
* unexpected failures. We don't want to break the QEMU
|
||||||
* driver in this scenario, so log errors & carry on
|
* driver in this scenario, so log errors & carry on
|
||||||
*/
|
*/
|
||||||
if (nodeCapsInitNUMA(caps) < 0) {
|
if (nodeCapsInitNUMA(NULL, caps) < 0) {
|
||||||
virCapabilitiesFreeNUMAInfo(caps);
|
virCapabilitiesFreeNUMAInfo(caps);
|
||||||
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
|
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ static virCapsPtr vboxCapsInit(void)
|
|||||||
false, false)) == NULL)
|
false, false)) == NULL)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (nodeCapsInitNUMA(caps) < 0)
|
if (nodeCapsInitNUMA(NULL, caps) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if ((guest = virCapabilitiesAddGuest(caps,
|
if ((guest = virCapabilitiesAddGuest(caps,
|
||||||
|
@ -68,7 +68,7 @@ vmwareCapsInit(void)
|
|||||||
false, false)) == NULL)
|
false, false)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (nodeCapsInitNUMA(caps) < 0)
|
if (nodeCapsInitNUMA(NULL, caps) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* i686 guests are always supported */
|
/* i686 guests are always supported */
|
||||||
|
@ -122,7 +122,7 @@ vzBuildCapabilities(void)
|
|||||||
false, false)) == NULL)
|
false, false)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (nodeCapsInitNUMA(caps) < 0)
|
if (nodeCapsInitNUMA(NULL, caps) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user