nodeinfo: Add sysfs_prefix to nodeGetMemoryStats

Add the sysfs_prefix argument to the call to allow for setting the
path for tests to something other than SYSFS_SYSTEM_PATH.
This commit is contained in:
John Ferlan 2015-07-07 17:37:36 -04:00
parent b97b30480d
commit c71f0654fc
7 changed files with 11 additions and 8 deletions

View File

@ -1121,7 +1121,7 @@ bhyveNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
return nodeGetMemoryStats(cellNum, params, nparams, flags);
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
}
static int

View File

@ -5486,7 +5486,7 @@ lxcNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
return nodeGetMemoryStats(cellNum, params, nparams, flags);
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
}

View File

@ -1141,7 +1141,8 @@ int nodeGetCPUStats(int cpuNum ATTRIBUTE_UNUSED,
#endif
}
int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
int nodeGetMemoryStats(const char *sysfs_prefix ATTRIBUTE_UNUSED,
int cellNum ATTRIBUTE_UNUSED,
virNodeMemoryStatsPtr params ATTRIBUTE_UNUSED,
int *nparams ATTRIBUTE_UNUSED,
unsigned int flags)
@ -1151,6 +1152,7 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
#ifdef __linux__
{
int ret;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
char *meminfo_path = NULL;
FILE *meminfo;
int max_node;
@ -1170,7 +1172,7 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
}
if (virAsprintf(&meminfo_path, "%s/node/node%d/meminfo",
SYSFS_SYSTEM_PATH, cellNum) < 0)
prefix, cellNum) < 0)
return -1;
}
meminfo = fopen(meminfo_path, "r");

View File

@ -33,7 +33,8 @@ int nodeGetCPUStats(int cpuNum,
virNodeCPUStatsPtr params,
int *nparams,
unsigned int flags);
int nodeGetMemoryStats(int cellNum,
int nodeGetMemoryStats(const char *sysfs_prefix,
int cellNum,
virNodeMemoryStatsPtr params,
int *nparams,
unsigned int flags);

View File

@ -2177,7 +2177,7 @@ openvzNodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int *nparams,
unsigned int flags)
{
return nodeGetMemoryStats(cellNum, params, nparams, flags);
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
}

View File

@ -18434,7 +18434,7 @@ qemuNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
return nodeGetMemoryStats(cellNum, params, nparams, flags);
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
}

View File

@ -2810,7 +2810,7 @@ umlNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
return nodeGetMemoryStats(cellNum, params, nparams, flags);
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
}