diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index e6d5518742..3a558793db 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(&nodeinfo)) + if (nodeGetInfo(NULL, &nodeinfo)) goto error; cpu->type = VIR_CPU_TYPE_HOST; diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 68dff6c8d9..ba411a0af6 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1131,7 +1131,7 @@ bhyveNodeGetInfo(virConnectPtr conn, if (virNodeGetInfoEnsureACL(conn) < 0) return -1; - return nodeGetInfo(nodeinfo); + return nodeGetInfo(NULL, nodeinfo); } static int diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 31201a0e5a..e0e72ea91a 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5400,7 +5400,7 @@ lxcNodeGetInfo(virConnectPtr conn, if (virNodeGetInfoEnsureACL(conn) < 0) return -1; - return nodeGetInfo(nodeinfo); + return nodeGetInfo(NULL, nodeinfo); } diff --git a/src/nodeinfo.c b/src/nodeinfo.c index bf4f751e55..2d715fdb72 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -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); diff --git a/src/nodeinfo.h b/src/nodeinfo.h index 9e6904f2d4..ec537697e7 100644 --- a/src/nodeinfo.h +++ b/src/nodeinfo.h @@ -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, diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 49d78c68d6..a4c5c31dfd 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -637,7 +637,7 @@ openvzGetNodeCPUs(void) { virNodeInfo nodeinfo; - if (nodeGetInfo(&nodeinfo) < 0) + if (nodeGetInfo(NULL, &nodeinfo) < 0) return 0; return nodeinfo.cpus; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index fc6f101741..280b998371 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(nodeinfo); + return nodeGetInfo(NULL, nodeinfo); } diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2b339353bb..81e680539f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -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; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9b085559fe..fc089af236 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18406,7 +18406,7 @@ qemuNodeGetInfo(virConnectPtr conn, if (virNodeGetInfoEnsureACL(conn) < 0) return -1; - return nodeGetInfo(nodeinfo); + return nodeGetInfo(NULL, nodeinfo); } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 99162f72ad..86066160d5 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -2782,7 +2782,7 @@ umlNodeGetInfo(virConnectPtr conn, if (virNodeGetInfoEnsureACL(conn) < 0) return -1; - return nodeGetInfo(nodeinfo); + return nodeGetInfo(NULL, nodeinfo); } diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 813a171933..5615df5391 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -7537,7 +7537,7 @@ static int vboxNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) { - return nodeGetInfo(nodeinfo); + return nodeGetInfo(NULL, nodeinfo); } static int diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index bfa901dd45..254fcbd4d2 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -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)