mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
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:
parent
f1c6179f0d
commit
29e4f2243f
@ -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;
|
||||
|
@ -1131,7 +1131,7 @@ bhyveNodeGetInfo(virConnectPtr conn,
|
||||
if (virNodeGetInfoEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
return nodeGetInfo(nodeinfo);
|
||||
return nodeGetInfo(NULL, nodeinfo);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -5400,7 +5400,7 @@ lxcNodeGetInfo(virConnectPtr conn,
|
||||
if (virNodeGetInfoEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
return nodeGetInfo(nodeinfo);
|
||||
return nodeGetInfo(NULL, nodeinfo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -637,7 +637,7 @@ openvzGetNodeCPUs(void)
|
||||
{
|
||||
virNodeInfo nodeinfo;
|
||||
|
||||
if (nodeGetInfo(&nodeinfo) < 0)
|
||||
if (nodeGetInfo(NULL, &nodeinfo) < 0)
|
||||
return 0;
|
||||
|
||||
return nodeinfo.cpus;
|
||||
|
@ -2155,7 +2155,7 @@ static int
|
||||
openvzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virNodeInfoPtr nodeinfo)
|
||||
{
|
||||
return nodeGetInfo(nodeinfo);
|
||||
return nodeGetInfo(NULL, nodeinfo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -18406,7 +18406,7 @@ qemuNodeGetInfo(virConnectPtr conn,
|
||||
if (virNodeGetInfoEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
return nodeGetInfo(nodeinfo);
|
||||
return nodeGetInfo(NULL, nodeinfo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2782,7 +2782,7 @@ umlNodeGetInfo(virConnectPtr conn,
|
||||
if (virNodeGetInfoEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
return nodeGetInfo(nodeinfo);
|
||||
return nodeGetInfo(NULL, nodeinfo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7537,7 +7537,7 @@ static int
|
||||
vboxNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virNodeInfoPtr nodeinfo)
|
||||
{
|
||||
return nodeGetInfo(nodeinfo);
|
||||
return nodeGetInfo(NULL, nodeinfo);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user