Nearly all the methods in the nodeinfo file are given a
'const char *sysfs_prefix' parameter to override the
default sysfs path (/sys/devices/system). Every single
caller passes in NULL for this, except one use in the
unit tests. Furthermore this parameter is totally
Linux-specific, when the APIs are intended to be cross
platform portable.
This removes the sysfs_prefix parameter and instead gives
a new method linuxNodeInfoSetSysFSSystemPath for use by
the test suite.
For two of the methods this hardcodes use of the constant
SYSFS_SYSTEM_PATH, since the test suite does not need to
override the path for thos methods.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/bhyve/bhyve_capabilities.c | 2 +-
src/bhyve/bhyve_driver.c | 6 +--
src/libvirt_linux.syms | 1 +
src/lxc/lxc_conf.c | 2 +-
src/lxc/lxc_controller.c | 2 +-
src/lxc/lxc_driver.c | 6 +--
src/nodeinfo.c | 112 +++++++++++++++++++----------------------
src/nodeinfo.h | 16 +++---
src/nodeinfopriv.h | 5 +-
src/openvz/openvz_conf.c | 4 +-
src/openvz/openvz_driver.c | 6 +--
src/phyp/phyp_driver.c | 2 +-
src/qemu/qemu_capabilities.c | 4 +-
src/qemu/qemu_driver.c | 12 ++---
src/qemu/qemu_process.c | 2 +-
src/uml/uml_conf.c | 2 +-
src/uml/uml_driver.c | 6 +--
src/util/vircgroup.c | 2 +-
src/vbox/vbox_common.c | 4 +-
src/vmware/vmware_conf.c | 2 +-
src/vz/vz_driver.c | 10 ++--
src/vz/vz_sdk.c | 2 +-
tests/nodeinfotest.c | 9 ++--
tests/vircgrouptest.c | 4 +-
24 files changed, 108 insertions(+), 115 deletions(-)
diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 93faaed..d0af4d9 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -51,7 +51,7 @@ virBhyveCapsInitCPU(virCapsPtr caps,
cpu->arch = arch;
- if (nodeGetInfo(NULL, &nodeinfo))
+ if (nodeGetInfo(&nodeinfo))
goto error;
cpu->type = VIR_CPU_TYPE_HOST;
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 5526bb0..b8060d5 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1148,7 +1148,7 @@ bhyveNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
- return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
+ return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
static int
@@ -1158,7 +1158,7 @@ bhyveNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
- return nodeGetInfo(NULL, nodeinfo);
+ return nodeGetInfo(nodeinfo);
}
static int
@@ -1334,7 +1334,7 @@ bhyveNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1;
- return nodeGetCPUMap(NULL, cpumap, online, flags);
+ return nodeGetCPUMap(cpumap, online, flags);
}
static int
diff --git a/src/libvirt_linux.syms b/src/libvirt_linux.syms
index 1a7f263..f569a23 100644
--- a/src/libvirt_linux.syms
+++ b/src/libvirt_linux.syms
@@ -5,6 +5,7 @@
# nodeinfo.h
linuxNodeGetCPUStats;
linuxNodeInfoCPUPopulate;
+linuxNodeInfoSetSysFSSystemPath;
# Let emacs know we want case-insensitive sorting
# Local Variables:
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 8ada531..96a0f47 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -77,7 +77,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
* unexpected failures. We don't want to break the lxc
* driver in this scenario, so log errors & carry on
*/
- if (nodeCapsInitNUMA(NULL, caps) < 0) {
+ if (nodeCapsInitNUMA(caps) < 0) {
virCapabilitiesFreeNUMAInfo(caps);
VIR_WARN("Failed to query host NUMA topology, disabling NUMA
capabilities");
}
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 8b5ec4c..a566c12 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -723,7 +723,7 @@ static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
/* setaffinity fails if you set bits for CPUs which
* aren't present, so we have to limit ourselves */
- if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
+ if ((hostcpus = nodeGetCPUCount()) < 0)
return -1;
if (maxcpu > hostcpus)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index ef48812..e7f66cc 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -5368,7 +5368,7 @@ lxcNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
- return nodeGetInfo(NULL, nodeinfo);
+ return nodeGetInfo(nodeinfo);
}
@@ -5454,7 +5454,7 @@ lxcNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
- return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
+ return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
@@ -5521,7 +5521,7 @@ lxcNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1;
- return nodeGetCPUMap(NULL, cpumap, online, flags);
+ return nodeGetCPUMap(cpumap, online, flags);
}
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 77ea155..1288543 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -65,7 +65,6 @@
VIR_LOG_INIT("nodeinfo");
-#define SYSFS_SYSTEM_PATH "/sys/devices/system"
#if defined(__FreeBSD__) || defined(__APPLE__)
static int
@@ -290,6 +289,7 @@ freebsdNodeGetMemoryStats(virNodeMemoryStatsPtr params,
#endif /* __FreeBSD__ */
#ifdef __linux__
+# define SYSFS_SYSTEM_PATH "/sys/devices/system"
# define CPUINFO_PATH "/proc/cpuinfo"
# define PROCSTAT_PATH "/proc/stat"
# define MEMINFO_PATH "/proc/meminfo"
@@ -300,6 +300,16 @@ freebsdNodeGetMemoryStats(virNodeMemoryStatsPtr params,
# define LINUX_NB_MEMORY_STATS_ALL 4
# define LINUX_NB_MEMORY_STATS_CELL 2
+static const char *sysfs_system_path = SYSFS_SYSTEM_PATH;
+
+void linuxNodeInfoSetSysFSSystemPath(const char *path)
+{
+ if (path)
+ sysfs_system_path = path;
+ else
+ sysfs_system_path = SYSFS_SYSTEM_PATH;
+}
+
/* Return the positive decimal contents of the given
* DIR/cpu%u/FILE, or -1 on error. If DEFAULT_VALUE is non-negative
* and the file could not be found, return that instead of an error;
@@ -593,8 +603,7 @@ virNodeParseNode(const char *node,
* A valid configuration is one where no secondary thread is online;
* the primary thread in a subcore is always the first one */
static bool
-nodeHasValidSubcoreConfiguration(const char *sysfs_prefix,
- int threads_per_subcore)
+nodeHasValidSubcoreConfiguration(int threads_per_subcore)
{
virBitmapPtr online_cpus = NULL;
int cpu = -1;
@@ -604,7 +613,7 @@ nodeHasValidSubcoreConfiguration(const char *sysfs_prefix,
if (threads_per_subcore <= 0)
goto cleanup;
- if (!(online_cpus = nodeGetOnlineCPUBitmap(sysfs_prefix)))
+ if (!(online_cpus = nodeGetOnlineCPUBitmap()))
goto cleanup;
while ((cpu = virBitmapNextSetBit(online_cpus, cpu)) >= 0) {
@@ -624,12 +633,10 @@ nodeHasValidSubcoreConfiguration(const char *sysfs_prefix,
}
int
-linuxNodeInfoCPUPopulate(const char *sysfs_prefix,
- FILE *cpuinfo,
+linuxNodeInfoCPUPopulate(FILE *cpuinfo,
virArch arch,
virNodeInfoPtr nodeinfo)
{
- const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
virBitmapPtr present_cpus_map = NULL;
virBitmapPtr online_cpus_map = NULL;
char line[1024];
@@ -726,17 +733,17 @@ linuxNodeInfoCPUPopulate(const char *sysfs_prefix,
/* Get information about what CPUs are present in the host and what
* CPUs are online, so that we don't have to so for each node */
- present_cpus_map = nodeGetPresentCPUBitmap(sysfs_prefix);
+ present_cpus_map = nodeGetPresentCPUBitmap();
if (!present_cpus_map)
goto cleanup;
- online_cpus_map = nodeGetOnlineCPUBitmap(sysfs_prefix);
+ online_cpus_map = nodeGetOnlineCPUBitmap();
if (!online_cpus_map)
goto cleanup;
/* OK, we've parsed clock speed out of /proc/cpuinfo. Get the
* core, node, socket, thread and topology information from /sys
*/
- if (virAsprintf(&sysfs_nodedir, "%s/node", prefix) < 0)
+ if (virAsprintf(&sysfs_nodedir, "%s/node", sysfs_system_path) < 0)
goto cleanup;
if (!(nodedir = opendir(sysfs_nodedir))) {
@@ -771,7 +778,7 @@ linuxNodeInfoCPUPopulate(const char *sysfs_prefix,
/* If the subcore configuration is not valid, just pretend subcores
* are not in use and count threads one by one */
- if (!nodeHasValidSubcoreConfiguration(sysfs_prefix, threads_per_subcore))
+ if (!nodeHasValidSubcoreConfiguration(threads_per_subcore))
threads_per_subcore = 0;
while ((direrr = virDirRead(nodedir, &nodedirent, sysfs_nodedir)) > 0) {
@@ -781,7 +788,7 @@ linuxNodeInfoCPUPopulate(const char *sysfs_prefix,
nodeinfo->nodes++;
if (virAsprintf(&sysfs_cpudir, "%s/node/%s",
- prefix, nodedirent->d_name) < 0)
+ sysfs_system_path, nodedirent->d_name) < 0)
goto cleanup;
if ((cpus = virNodeParseNode(sysfs_cpudir, arch,
@@ -815,7 +822,7 @@ linuxNodeInfoCPUPopulate(const char *sysfs_prefix,
fallback:
VIR_FREE(sysfs_cpudir);
- if (virAsprintf(&sysfs_cpudir, "%s/cpu", prefix) < 0)
+ if (virAsprintf(&sysfs_cpudir, "%s/cpu", sysfs_system_path) < 0)
goto cleanup;
if ((cpus = virNodeParseNode(sysfs_cpudir, arch,
@@ -1079,28 +1086,26 @@ linuxNodeGetMemoryStats(FILE *meminfo,
}
static char *
-linuxGetCPUGlobalPath(const char *sysfs_prefix,
- const char *file)
+linuxGetCPUGlobalPath(const char *file)
{
- const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
char *path = NULL;
- if (virAsprintf(&path, "%s/cpu/%s", prefix, file) < 0)
+ if (virAsprintf(&path, "%s/cpu/%s", sysfs_system_path, file) < 0)
return NULL;
return path;
}
static char *
-linuxGetCPUPresentPath(const char *sysfs_prefix)
+linuxGetCPUPresentPath(void)
{
- return linuxGetCPUGlobalPath(sysfs_prefix, "present");
+ return linuxGetCPUGlobalPath("present");
}
static char *
-linuxGetCPUOnlinePath(const char *sysfs_prefix)
+linuxGetCPUOnlinePath(void)
{
- return linuxGetCPUGlobalPath(sysfs_prefix, "online");
+ return linuxGetCPUGlobalPath("online");
}
/* Determine the number of CPUs (maximum CPU id + 1) from a file containing
@@ -1184,8 +1189,7 @@ virNodeGetSiblingsList(const char *dir, int cpu_id)
#endif
int
-nodeGetInfo(const char *sysfs_prefix ATTRIBUTE_UNUSED,
- virNodeInfoPtr nodeinfo)
+nodeGetInfo(virNodeInfoPtr nodeinfo)
{
virArch hostarch = virArchFromHost();
@@ -1205,8 +1209,7 @@ nodeGetInfo(const char *sysfs_prefix ATTRIBUTE_UNUSED,
return -1;
}
- ret = linuxNodeInfoCPUPopulate(sysfs_prefix, cpuinfo,
- hostarch, nodeinfo);
+ ret = linuxNodeInfoCPUPopulate(cpuinfo, hostarch, nodeinfo);
if (ret < 0)
goto cleanup;
@@ -1293,8 +1296,7 @@ nodeGetCPUStats(int cpuNum ATTRIBUTE_UNUSED,
}
int
-nodeGetMemoryStats(const char *sysfs_prefix ATTRIBUTE_UNUSED,
- int cellNum ATTRIBUTE_UNUSED,
+nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
virNodeMemoryStatsPtr params ATTRIBUTE_UNUSED,
int *nparams ATTRIBUTE_UNUSED,
unsigned int flags)
@@ -1304,7 +1306,6 @@ nodeGetMemoryStats(const char *sysfs_prefix 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;
@@ -1323,8 +1324,9 @@ nodeGetMemoryStats(const char *sysfs_prefix ATTRIBUTE_UNUSED,
return -1;
}
- if (virAsprintf(&meminfo_path, "%s/node/node%d/meminfo",
- prefix, cellNum) < 0)
+ if (virAsprintf(&meminfo_path,
+ SYSFS_SYSTEM_PATH "/node/node%d/meminfo",
+ cellNum) < 0)
return -1;
}
meminfo = fopen(meminfo_path, "r");
@@ -1351,7 +1353,7 @@ nodeGetMemoryStats(const char *sysfs_prefix ATTRIBUTE_UNUSED,
}
int
-nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
+nodeGetCPUCount(void)
{
#if defined(__linux__)
/* To support older kernels that lack cpu/present, such as 2.6.18
@@ -1360,11 +1362,10 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
* will be consecutive.
*/
char *present_path = NULL;
- const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
char *cpupath = NULL;
int ncpu = -1;
- if (!(present_path = linuxGetCPUPresentPath(sysfs_prefix)))
+ if (!(present_path = linuxGetCPUPresentPath()))
return -1;
if (virFileExists(present_path)) {
@@ -1372,7 +1373,7 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
goto cleanup;
}
- if (virAsprintf(&cpupath, "%s/cpu/cpu0", prefix) < 0)
+ if (virAsprintf(&cpupath, "%s/cpu/cpu0", sysfs_system_path) < 0)
goto cleanup;
if (virFileExists(cpupath)) {
ncpu = 0;
@@ -1380,7 +1381,7 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
ncpu++;
VIR_FREE(cpupath);
if (virAsprintf(&cpupath, "%s/cpu/cpu%d",
- prefix, ncpu) < 0) {
+ sysfs_system_path, ncpu) < 0) {
ncpu = -1;
goto cleanup;
}
@@ -1405,17 +1406,17 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
}
virBitmapPtr
-nodeGetPresentCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED)
+nodeGetPresentCPUBitmap(void)
{
#ifdef __linux__
virBitmapPtr present_cpus = NULL;
char *present_path = NULL;
int npresent_cpus;
- if ((npresent_cpus = nodeGetCPUCount(sysfs_prefix)) < 0)
+ if ((npresent_cpus = nodeGetCPUCount()) < 0)
goto cleanup;
- if (!(present_path = linuxGetCPUPresentPath(sysfs_prefix)))
+ if (!(present_path = linuxGetCPUPresentPath()))
goto cleanup;
/* If the cpu/present file is available, parse it and exit */
@@ -1443,20 +1444,19 @@ nodeGetPresentCPUBitmap(const char *sysfs_prefix
ATTRIBUTE_UNUSED)
}
virBitmapPtr
-nodeGetOnlineCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED)
+nodeGetOnlineCPUBitmap(void)
{
#ifdef __linux__
- const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
char *online_path = NULL;
char *cpudir = NULL;
virBitmapPtr cpumap;
int present;
- present = nodeGetCPUCount(sysfs_prefix);
+ present = nodeGetCPUCount();
if (present < 0)
return NULL;
- if (!(online_path = linuxGetCPUOnlinePath(sysfs_prefix)))
+ if (!(online_path = linuxGetCPUOnlinePath()))
return NULL;
if (virFileExists(online_path)) {
cpumap = linuxParseCPUmap(present, online_path);
@@ -1467,7 +1467,7 @@ nodeGetOnlineCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED)
if (!cpumap)
goto cleanup;
- if (virAsprintf(&cpudir, "%s/cpu", prefix) < 0)
+ if (virAsprintf(&cpudir, "%s/cpu", sysfs_system_path) < 0)
goto cleanup;
for (i = 0; i < present; i++) {
@@ -1796,8 +1796,7 @@ nodeGetMemoryParameters(virTypedParameterPtr params
ATTRIBUTE_UNUSED,
}
int
-nodeGetCPUMap(const char *sysfs_prefix,
- unsigned char **cpumap,
+nodeGetCPUMap(unsigned char **cpumap,
unsigned int *online,
unsigned int flags)
{
@@ -1808,9 +1807,9 @@ nodeGetCPUMap(const char *sysfs_prefix,
virCheckFlags(0, -1);
if (!cpumap && !online)
- return nodeGetCPUCount(sysfs_prefix);
+ return nodeGetCPUCount();
- if (!(cpus = nodeGetOnlineCPUBitmap(sysfs_prefix)))
+ if (!(cpus = nodeGetOnlineCPUBitmap()))
goto cleanup;
if (cpumap && virBitmapToData(cpus, cpumap, &dummy) < 0)
@@ -1828,8 +1827,7 @@ nodeGetCPUMap(const char *sysfs_prefix,
}
static int
-nodeCapsInitNUMAFake(const char *sysfs_prefix,
- const char *cpupath ATTRIBUTE_UNUSED,
+nodeCapsInitNUMAFake(const char *cpupath ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED)
{
virNodeInfo nodeinfo;
@@ -1839,7 +1837,7 @@ nodeCapsInitNUMAFake(const char *sysfs_prefix,
int id, cid;
int onlinecpus ATTRIBUTE_UNUSED;
- if (nodeGetInfo(sysfs_prefix, &nodeinfo) < 0)
+ if (nodeGetInfo(&nodeinfo) < 0)
return -1;
ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
@@ -2088,11 +2086,8 @@ virNodeCapsGetPagesInfo(int node,
}
int
-nodeCapsInitNUMA(const char *sysfs_prefix,
- virCapsPtr caps)
+nodeCapsInitNUMA(virCapsPtr caps)
{
- const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
- char *cpupath;
int n;
unsigned long long memory;
virCapsHostNUMACellCPUPtr cpus = NULL;
@@ -2107,11 +2102,8 @@ nodeCapsInitNUMA(const char *sysfs_prefix,
bool topology_failed = false;
int max_node;
- if (virAsprintf(&cpupath, "%s/cpu", prefix) < 0)
- return -1;
-
if (!virNumaIsAvailable()) {
- ret = nodeCapsInitNUMAFake(sysfs_prefix, cpupath, caps);
+ ret = nodeCapsInitNUMAFake(SYSFS_SYSTEM_PATH "/cpu", caps);
goto cleanup;
}
@@ -2134,7 +2126,8 @@ nodeCapsInitNUMA(const char *sysfs_prefix,
for (i = 0; i < virBitmapSize(cpumap); i++) {
if (virBitmapIsBitSet(cpumap, i)) {
- if (virNodeCapsFillCPUInfo(cpupath, i, cpus + cpu++) < 0) {
+ if (virNodeCapsFillCPUInfo(SYSFS_SYSTEM_PATH "/cpu",
+ i, cpus + cpu++) < 0) {
topology_failed = true;
virResetLastError();
}
@@ -2174,7 +2167,6 @@ nodeCapsInitNUMA(const char *sysfs_prefix,
VIR_FREE(cpus);
VIR_FREE(siblings);
VIR_FREE(pageinfo);
- VIR_FREE(cpupath);
return ret;
}
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
index ac96dca..b4f434e 100644
--- a/src/nodeinfo.h
+++ b/src/nodeinfo.h
@@ -26,15 +26,14 @@
# include "capabilities.h"
-int nodeGetInfo(const char *sysfs_prefix, virNodeInfoPtr nodeinfo);
-int nodeCapsInitNUMA(const char *sysfs_prefix, virCapsPtr caps);
+int nodeGetInfo(virNodeInfoPtr nodeinfo);
+int nodeCapsInitNUMA(virCapsPtr caps);
int nodeGetCPUStats(int cpuNum,
virNodeCPUStatsPtr params,
int *nparams,
unsigned int flags);
-int nodeGetMemoryStats(const char *sysfs_prefix,
- int cellNum,
+int nodeGetMemoryStats(int cellNum,
virNodeMemoryStatsPtr params,
int *nparams,
unsigned int flags);
@@ -44,9 +43,9 @@ int nodeGetCellsFreeMemory(unsigned long long *freeMems,
int nodeGetMemory(unsigned long long *mem,
unsigned long long *freeMem);
-virBitmapPtr nodeGetPresentCPUBitmap(const char *sysfs_prefix);
-virBitmapPtr nodeGetOnlineCPUBitmap(const char *sysfs_prefix);
-int nodeGetCPUCount(const char *sysfs_prefix);
+virBitmapPtr nodeGetPresentCPUBitmap(void);
+virBitmapPtr nodeGetOnlineCPUBitmap(void);
+int nodeGetCPUCount(void);
int nodeGetThreadsPerSubcore(virArch arch);
int nodeGetMemoryParameters(virTypedParameterPtr params,
@@ -57,8 +56,7 @@ int nodeSetMemoryParameters(virTypedParameterPtr params,
int nparams,
unsigned int flags);
-int nodeGetCPUMap(const char *sysfs_prefix,
- unsigned char **cpumap,
+int nodeGetCPUMap(unsigned char **cpumap,
unsigned int *online,
unsigned int flags);
diff --git a/src/nodeinfopriv.h b/src/nodeinfopriv.h
index 1aab4ad..4fe489a 100644
--- a/src/nodeinfopriv.h
+++ b/src/nodeinfopriv.h
@@ -25,8 +25,9 @@
# include "nodeinfo.h"
# ifdef __linux__
-int linuxNodeInfoCPUPopulate(const char *sysfs_prefix,
- FILE *cpuinfo,
+void linuxNodeInfoSetSysFSSystemPath(const char *path);
+
+int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
virArch arch,
virNodeInfoPtr nodeinfo);
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 4103d69..820dc22 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -165,7 +165,7 @@ virCapsPtr openvzCapsInit(void)
false, false)) == NULL)
goto no_memory;
- if (nodeCapsInitNUMA(NULL, caps) < 0)
+ if (nodeCapsInitNUMA(caps) < 0)
goto no_memory;
if ((guest = virCapabilitiesAddGuest(caps,
@@ -633,7 +633,7 @@ openvzGetNodeCPUs(void)
{
virNodeInfo nodeinfo;
- if (nodeGetInfo(NULL, &nodeinfo) < 0)
+ if (nodeGetInfo(&nodeinfo) < 0)
return 0;
return nodeinfo.cpus;
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index e154a0f..24a20cc 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2155,7 +2155,7 @@ static int
openvzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
- return nodeGetInfo(NULL, nodeinfo);
+ return nodeGetInfo(nodeinfo);
}
@@ -2177,7 +2177,7 @@ openvzNodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int *nparams,
unsigned int flags)
{
- return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
+ return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
@@ -2207,7 +2207,7 @@ openvzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned int *online,
unsigned int flags)
{
- return nodeGetCPUMap(NULL, cpumap, online, flags);
+ return nodeGetCPUMap(cpumap, online, flags);
}
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 55a63e7..eb5c378 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -335,7 +335,7 @@ phypCapsInit(void)
* unexpected failures. We don't want to break the QEMU
* driver in this scenario, so log errors & carry on
*/
- if (nodeCapsInitNUMA(NULL, caps) < 0) {
+ if (nodeCapsInitNUMA(caps) < 0) {
virCapabilitiesFreeNUMAInfo(caps);
VIR_WARN
("Failed to query host NUMA topology, disabling NUMA
capabilities");
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b73c296..3466b72 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1000,7 +1000,7 @@ virQEMUCapsInitCPU(virCapsPtr caps,
cpu->arch = arch;
- if (nodeGetInfo(NULL, &nodeinfo))
+ if (nodeGetInfo(&nodeinfo))
goto error;
cpu->type = VIR_CPU_TYPE_HOST;
@@ -1063,7 +1063,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
* unexpected failures. We don't want to break the QEMU
* driver in this scenario, so log errors & carry on
*/
- if (nodeCapsInitNUMA(NULL, caps) < 0) {
+ if (nodeCapsInitNUMA(caps) < 0) {
virCapabilitiesFreeNUMAInfo(caps);
VIR_WARN("Failed to query host NUMA topology, disabling NUMA
capabilities");
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index eaabe58..79447e9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5148,7 +5148,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
priv = vm->privateData;
ret = virDomainDefGetVcpuPinInfoHelper(def, maplen, ncpumaps, cpumaps,
- nodeGetCPUCount(NULL),
+ nodeGetCPUCount(),
priv->autoCpuset);
cleanup:
virDomainObjEndAPI(&vm);
@@ -5293,7 +5293,7 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
if (!(def = virDomainObjGetOneDef(vm, flags)))
goto cleanup;
- if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
+ if ((hostcpus = nodeGetCPUCount()) < 0)
goto cleanup;
priv = vm->privateData;
@@ -5541,7 +5541,7 @@ qemuDomainGetIOThreadsConfig(virDomainDefPtr targetDef,
if (targetDef->niothreadids == 0)
return 0;
- if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
+ if ((hostcpus = nodeGetCPUCount()) < 0)
goto cleanup;
if (VIR_ALLOC_N(info_ret, targetDef->niothreadids) < 0)
@@ -18510,7 +18510,7 @@ qemuNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
- return nodeGetInfo(NULL, nodeinfo);
+ return nodeGetInfo(nodeinfo);
}
@@ -18538,7 +18538,7 @@ qemuNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
- return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
+ return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
@@ -18605,7 +18605,7 @@ qemuNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1;
- return nodeGetCPUMap(NULL, cpumap, online, flags);
+ return nodeGetCPUMap(cpumap, online, flags);
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b1e270f..274b4d4 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2194,7 +2194,7 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
/* setaffinity fails if you set bits for CPUs which
* aren't present, so we have to limit ourselves */
- if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
+ if ((hostcpus = nodeGetCPUCount()) < 0)
goto cleanup;
if (hostcpus > QEMUD_CPUMASK_LEN)
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index afc0375..a97ae64 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -65,7 +65,7 @@ virCapsPtr umlCapsInit(void)
* unexpected failures. We don't want to break the QEMU
* driver in this scenario, so log errors & carry on
*/
- if (nodeCapsInitNUMA(NULL, caps) < 0) {
+ if (nodeCapsInitNUMA(caps) < 0) {
virCapabilitiesFreeNUMAInfo(caps);
VIR_WARN("Failed to query host NUMA topology, disabling NUMA
capabilities");
}
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 84e1df8..1c7a36d 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -2778,7 +2778,7 @@ umlNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
- return nodeGetInfo(NULL, nodeinfo);
+ return nodeGetInfo(nodeinfo);
}
@@ -2806,7 +2806,7 @@ umlNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
- return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
+ return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
@@ -2873,7 +2873,7 @@ umlNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1;
- return nodeGetCPUMap(NULL, cpumap, online, flags);
+ return nodeGetCPUMap(cpumap, online, flags);
}
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index bffd88f..1b90447 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -3131,7 +3131,7 @@ virCgroupGetPercpuStats(virCgroupPtr group,
}
/* To parse account file, we need to know how many cpus are present. */
- if (!(cpumap = nodeGetPresentCPUBitmap(NULL)))
+ if (!(cpumap = nodeGetPresentCPUBitmap()))
return -1;
total_cpus = virBitmapSize(cpumap);
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 0cead10..02a7231 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -317,7 +317,7 @@ static virCapsPtr vboxCapsInit(void)
false, false)) == NULL)
goto no_memory;
- if (nodeCapsInitNUMA(NULL, caps) < 0)
+ if (nodeCapsInitNUMA(caps) < 0)
goto no_memory;
if ((guest = virCapabilitiesAddGuest(caps,
@@ -7522,7 +7522,7 @@ static int
vboxNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
- return nodeGetInfo(NULL, nodeinfo);
+ return nodeGetInfo(nodeinfo);
}
static int
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index b30b5de..8736976 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -68,7 +68,7 @@ vmwareCapsInit(void)
false, false)) == NULL)
goto error;
- if (nodeCapsInitNUMA(NULL, caps) < 0)
+ if (nodeCapsInitNUMA(caps) < 0)
goto error;
/* i686 guests are always supported */
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index d2bf54e..3e1a4f5 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -115,7 +115,7 @@ vzBuildCapabilities(void)
false, false)) == NULL)
return NULL;
- if (nodeCapsInitNUMA(NULL, caps) < 0)
+ if (nodeCapsInitNUMA(caps) < 0)
goto error;
for (i = 0; i < 2; i++)
@@ -125,7 +125,7 @@ vzBuildCapabilities(void)
emulators[k], virt_types[k]) < 0)
goto error;
- if (nodeGetInfo(NULL, &nodeinfo))
+ if (nodeGetInfo(&nodeinfo))
goto error;
if (VIR_ALLOC(cpu) < 0)
@@ -804,7 +804,7 @@ static int
vzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
- return nodeGetInfo(NULL, nodeinfo);
+ return nodeGetInfo(nodeinfo);
}
static int vzConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
@@ -891,7 +891,7 @@ vzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned int *online,
unsigned int flags)
{
- return nodeGetCPUMap(NULL, cpumap, online, flags);
+ return nodeGetCPUMap(cpumap, online, flags);
}
static int
@@ -1457,7 +1457,7 @@ vzNodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int *nparams,
unsigned int flags)
{
- return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
+ return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
static int
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 01de4f6..eb79be7 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1125,7 +1125,7 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom,
PRL_RESULT pret;
int ret = -1;
- if ((hostcpus = nodeGetCPUCount(NULL)) < 0)
+ if ((hostcpus = nodeGetCPUCount()) < 0)
goto cleanup;
/* get number of CPUs */
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index d8eace5..8d93024 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -24,8 +24,7 @@ main(void)
#else
static int
-linuxTestCompareFiles(char *sysfs_prefix,
- const char *cpuinfofile,
+linuxTestCompareFiles(const char *cpuinfofile,
virArch arch,
const char *outputfile)
{
@@ -42,7 +41,7 @@ linuxTestCompareFiles(char *sysfs_prefix,
}
memset(&nodeinfo, 0, sizeof(nodeinfo));
- if (linuxNodeInfoCPUPopulate(sysfs_prefix, cpuinfo, arch, &nodeinfo) < 0) {
+ if (linuxNodeInfoCPUPopulate(cpuinfo, arch, &nodeinfo) < 0) {
if (virTestGetDebug()) {
virErrorPtr error = virSaveLastError();
if (error && error->code != VIR_ERR_OK)
@@ -177,7 +176,9 @@ linuxTestNodeInfo(const void *opaque)
goto cleanup;
}
- result = linuxTestCompareFiles(sysfs_prefix, cpuinfo, data->arch, output);
+ linuxNodeInfoSetSysFSSystemPath(sysfs_prefix);
+ result = linuxTestCompareFiles(cpuinfo, data->arch, output);
+ linuxNodeInfoSetSysFSSystemPath(NULL);
cleanup:
VIR_FREE(cpuinfo);
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index 322f6cb..6ce03f7 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -649,8 +649,8 @@ static int testCgroupGetPercpuStats(const void *args
ATTRIBUTE_UNUSED)
goto cleanup;
}
- if (nodeGetCPUCount(NULL) != EXPECTED_NCPUS) {
- fprintf(stderr, "Unexpected: nodeGetCPUCount() yields: %d\n",
nodeGetCPUCount(NULL));
+ if (nodeGetCPUCount() != EXPECTED_NCPUS) {
+ fprintf(stderr, "Unexpected: nodeGetCPUCount() yields: %d\n",
nodeGetCPUCount());
goto cleanup;
}
--
2.5.5