mirror of https://gitee.com/openkylin/libvirt.git
nodeinfo: Introduce linuxGetCPUGlobalPath()
This is just a more generic version of linuxGetCPUPresentPath(), which is now implemented by calling the new function appropriately.
This commit is contained in:
parent
2a6801892a
commit
bd87f07c25
|
@ -959,16 +959,24 @@ linuxNodeGetMemoryStats(FILE *meminfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
linuxGetCPUPresentPath(const char *sysfs_prefix)
|
linuxGetCPUGlobalPath(const char *sysfs_prefix,
|
||||||
|
const char *file)
|
||||||
{
|
{
|
||||||
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
|
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
|
|
||||||
if (virAsprintf(&path, "%s/cpu/present", prefix) < 0)
|
if (virAsprintf(&path, "%s/cpu/%s", prefix, file) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
linuxGetCPUPresentPath(const char *sysfs_prefix)
|
||||||
|
{
|
||||||
|
return linuxGetCPUGlobalPath(sysfs_prefix, "present");
|
||||||
|
}
|
||||||
|
|
||||||
/* Determine the maximum cpu id from a Linux sysfs cpu/present file. */
|
/* Determine the maximum cpu id from a Linux sysfs cpu/present file. */
|
||||||
static int
|
static int
|
||||||
linuxParseCPUmax(const char *path)
|
linuxParseCPUmax(const char *path)
|
||||||
|
|
Loading…
Reference in New Issue