nodeinfo: Add sysfs_prefix to nodeGetInfo

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 07:27:53 -04:00
parent f1c6179f0d
commit 29e4f2243f
12 changed files with 18 additions and 15 deletions

View File

@ -51,7 +51,7 @@ virBhyveCapsInitCPU(virCapsPtr caps,
cpu->arch = arch;
if (nodeGetInfo(&nodeinfo))
if (nodeGetInfo(NULL, &nodeinfo))
goto error;
cpu->type = VIR_CPU_TYPE_HOST;

View File

@ -1131,7 +1131,7 @@ bhyveNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
return nodeGetInfo(nodeinfo);
return nodeGetInfo(NULL, nodeinfo);
}
static int

View File

@ -5400,7 +5400,7 @@ lxcNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
return nodeGetInfo(nodeinfo);
return nodeGetInfo(NULL, nodeinfo);
}

View File

@ -1034,7 +1034,8 @@ virNodeGetSiblingsList(const char *dir, int cpu_id)
}
#endif
int nodeGetInfo(virNodeInfoPtr nodeinfo)
int nodeGetInfo(const char *sysfs_prefix ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
virArch hostarch = virArchFromHost();
@ -1046,14 +1047,16 @@ int nodeGetInfo(virNodeInfoPtr nodeinfo)
#ifdef __linux__
{
int ret = -1;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
FILE *cpuinfo = fopen(CPUINFO_PATH, "r");
if (!cpuinfo) {
virReportSystemError(errno,
_("cannot open %s"), CPUINFO_PATH);
return -1;
}
ret = linuxNodeInfoCPUPopulate(cpuinfo, SYSFS_SYSTEM_PATH,
ret = linuxNodeInfoCPUPopulate(cpuinfo, prefix,
hostarch, nodeinfo);
if (ret < 0)
goto cleanup;
@ -1666,7 +1669,7 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
int id, cid;
int onlinecpus ATTRIBUTE_UNUSED;
if (nodeGetInfo(&nodeinfo) < 0)
if (nodeGetInfo(NULL, &nodeinfo) < 0)
return -1;
ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo);

View File

@ -26,7 +26,7 @@
# include "capabilities.h"
int nodeGetInfo(virNodeInfoPtr nodeinfo);
int nodeGetInfo(const char *sysfs_prefix, virNodeInfoPtr nodeinfo);
int nodeCapsInitNUMA(virCapsPtr caps);
int nodeGetCPUStats(int cpuNum,

View File

@ -637,7 +637,7 @@ openvzGetNodeCPUs(void)
{
virNodeInfo nodeinfo;
if (nodeGetInfo(&nodeinfo) < 0)
if (nodeGetInfo(NULL, &nodeinfo) < 0)
return 0;
return nodeinfo.cpus;

View File

@ -2155,7 +2155,7 @@ static int
openvzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
return nodeGetInfo(nodeinfo);
return nodeGetInfo(NULL, nodeinfo);
}

View File

@ -961,7 +961,7 @@ virQEMUCapsInitCPU(virCapsPtr caps,
cpu->arch = arch;
if (nodeGetInfo(&nodeinfo))
if (nodeGetInfo(NULL, &nodeinfo))
goto error;
cpu->type = VIR_CPU_TYPE_HOST;

View File

@ -18406,7 +18406,7 @@ qemuNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
return nodeGetInfo(nodeinfo);
return nodeGetInfo(NULL, nodeinfo);
}

View File

@ -2782,7 +2782,7 @@ umlNodeGetInfo(virConnectPtr conn,
if (virNodeGetInfoEnsureACL(conn) < 0)
return -1;
return nodeGetInfo(nodeinfo);
return nodeGetInfo(NULL, nodeinfo);
}

View File

@ -7537,7 +7537,7 @@ static int
vboxNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
return nodeGetInfo(nodeinfo);
return nodeGetInfo(NULL, nodeinfo);
}
static int

View File

@ -132,7 +132,7 @@ vzBuildCapabilities(void)
emulators[k], virt_types[k]) < 0)
goto error;
if (nodeGetInfo(&nodeinfo))
if (nodeGetInfo(NULL, &nodeinfo))
goto error;
if (VIR_ALLOC(cpu) < 0)
@ -765,7 +765,7 @@ static int
vzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr nodeinfo)
{
return nodeGetInfo(nodeinfo);
return nodeGetInfo(NULL, nodeinfo);
}
static int vzConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)