Add the sysfs_prefix argument to the call to allow for setting the
path for tests to something other than SYSFS_SYSTEM_PATH.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/bhyve/bhyve_driver.c | 2 +-
src/lxc/lxc_driver.c | 2 +-
src/nodeinfo.c | 6 ++++--
src/nodeinfo.h | 3 ++-
src/openvz/openvz_driver.c | 2 +-
src/qemu/qemu_driver.c | 2 +-
src/uml/uml_driver.c | 2 +-
7 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index ba411a0..85b7c8f 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -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
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index e0e72ea..81bb711 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -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);
}
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 5ff5ce8..3c7e417 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -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");
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
index b28aaab..4f983c2 100644
--- a/src/nodeinfo.h
+++ b/src/nodeinfo.h
@@ -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);
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 280b998..fc8db7e 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -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);
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b26b1a8..8c475ef 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18405,7 +18405,7 @@ qemuNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
- return nodeGetMemoryStats(cellNum, params, nparams, flags);
+ return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
}
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 8606616..c3c5fa7 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -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);
}
--
2.1.0