nodeinfo: remove sysfs_prefix from all methods

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@redhat.com>
This commit is contained in:
Daniel P. Berrange 2016-04-13 15:28:55 +01:00
parent 5f4c50d528
commit 08ea852c25
24 changed files with 108 additions and 115 deletions

View File

@ -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;

View File

@ -1175,7 +1175,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
@ -1185,7 +1185,7 @@ bhyveNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
return nodeGetInfo(NULL, nodeinfo);
return nodeGetInfo(nodeinfo);
}
static int
@ -1361,7 +1361,7 @@ bhyveNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1;
return nodeGetCPUMap(NULL, cpumap, online, flags);
return nodeGetCPUMap(cpumap, online, flags);
}
static int

View File

@ -5,6 +5,7 @@
# nodeinfo.h
linuxNodeGetCPUStats;
linuxNodeInfoCPUPopulate;
linuxNodeInfoSetSysFSSystemPath;
# Let emacs know we want case-insensitive sorting
# Local Variables:

View File

@ -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");
}

View File

@ -730,7 +730,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)

View File

@ -5154,7 +5154,7 @@ lxcNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
return nodeGetInfo(NULL, nodeinfo);
return nodeGetInfo(nodeinfo);
}
@ -5246,7 +5246,7 @@ lxcNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
@ -5313,7 +5313,7 @@ lxcNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1;
return nodeGetCPUMap(NULL, cpumap, online, flags);
return nodeGetCPUMap(cpumap, online, flags);
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -2157,7 +2157,7 @@ static int
openvzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
return nodeGetInfo(NULL, nodeinfo);
return nodeGetInfo(nodeinfo);
}
@ -2179,7 +2179,7 @@ openvzNodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int *nparams,
unsigned int flags)
{
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
@ -2209,7 +2209,7 @@ openvzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned int *online,
unsigned int flags)
{
return nodeGetCPUMap(NULL, cpumap, online, flags);
return nodeGetCPUMap(cpumap, online, flags);
}

View File

@ -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");

View File

@ -1013,7 +1013,7 @@ virQEMUCapsInitCPU(virCapsPtr caps,
cpu->arch = arch;
if (nodeGetInfo(NULL, &nodeinfo))
if (nodeGetInfo(&nodeinfo))
goto error;
cpu->type = VIR_CPU_TYPE_HOST;
@ -1076,7 +1076,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");
}

View File

@ -5152,7 +5152,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
priv = vm->privateData;
ret = virDomainDefGetVcpuPinInfoHelper(def, maplen, ncpumaps, cpumaps,
nodeGetCPUCount(NULL),
nodeGetCPUCount(),
priv->autoCpuset);
cleanup:
virDomainObjEndAPI(&vm);
@ -5297,7 +5297,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;
@ -5545,7 +5545,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)
@ -18081,7 +18081,7 @@ qemuNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
return nodeGetInfo(NULL, nodeinfo);
return nodeGetInfo(nodeinfo);
}
@ -18109,7 +18109,7 @@ qemuNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
@ -18176,7 +18176,7 @@ qemuNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1;
return nodeGetCPUMap(NULL, cpumap, online, flags);
return nodeGetCPUMap(cpumap, online, flags);
}

View File

@ -2229,7 +2229,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)

View File

@ -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");
}

View File

@ -2774,7 +2774,7 @@ umlNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
return nodeGetInfo(NULL, nodeinfo);
return nodeGetInfo(nodeinfo);
}
@ -2802,7 +2802,7 @@ umlNodeGetMemoryStats(virConnectPtr conn,
if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
return -1;
return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags);
return nodeGetMemoryStats(cellNum, params, nparams, flags);
}
@ -2869,7 +2869,7 @@ umlNodeGetCPUMap(virConnectPtr conn,
if (virNodeGetCPUMapEnsureACL(conn) < 0)
return -1;
return nodeGetCPUMap(NULL, cpumap, online, flags);
return nodeGetCPUMap(cpumap, online, flags);
}

View File

@ -3147,7 +3147,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);

View File

@ -318,7 +318,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,
@ -7527,7 +7527,7 @@ static int
vboxNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
return nodeGetInfo(NULL, nodeinfo);
return nodeGetInfo(nodeinfo);
}
static int

View File

@ -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 */

View File

@ -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)
@ -832,7 +832,7 @@ static int
vzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
return nodeGetInfo(NULL, nodeinfo);
return nodeGetInfo(nodeinfo);
}
static int vzConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
@ -919,7 +919,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
@ -1487,7 +1487,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

View File

@ -1151,7 +1151,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 */

View File

@ -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()) {
if (virGetLastError())
VIR_TEST_DEBUG("\n%s\n", virGetLastErrorMessage());
@ -175,7 +174,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);

View File

@ -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;
}