mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
nodeinfo: Fix nodeGetCPUBitmap()'s fallback code path
During the recent refactoring/cleanups, a bug has been introduced that caused all CPUs to be reported as online unless the sysfs cpu/present file was available. This commit fixes the fallback code path by building the directory path passed to virNodeGetCpuValue() correctly.
This commit is contained in:
parent
c30ae1864f
commit
2a6801892a
@ -1301,6 +1301,7 @@ nodeGetCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED,
|
||||
#ifdef __linux__
|
||||
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
|
||||
char *online_path = NULL;
|
||||
char *cpudir = NULL;
|
||||
virBitmapPtr cpumap;
|
||||
int present;
|
||||
|
||||
@ -1318,8 +1319,12 @@ nodeGetCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED,
|
||||
cpumap = virBitmapNew(present);
|
||||
if (!cpumap)
|
||||
goto cleanup;
|
||||
|
||||
if (virAsprintf(&cpudir, "%s/cpu", prefix) < 0)
|
||||
goto cleanup;
|
||||
|
||||
for (i = 0; i < present; i++) {
|
||||
int online = virNodeGetCpuValue(prefix, i, "online", 1);
|
||||
int online = virNodeGetCpuValue(cpudir, i, "online", 1);
|
||||
if (online < 0) {
|
||||
virBitmapFree(cpumap);
|
||||
cpumap = NULL;
|
||||
@ -1333,6 +1338,7 @@ nodeGetCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED,
|
||||
*max_id = present;
|
||||
cleanup:
|
||||
VIR_FREE(online_path);
|
||||
VIR_FREE(cpudir);
|
||||
return cpumap;
|
||||
#else
|
||||
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||
|
Loading…
x
Reference in New Issue
Block a user