mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-27 15:05:17 +00:00
nodeinfo: Add sysfs_prefix to nodeGetPresentCPUBitmap
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
f1a43a0f91
commit
51281dcb90
@ -1249,19 +1249,20 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
virBitmapPtr
|
virBitmapPtr
|
||||||
nodeGetPresentCPUBitmap(void)
|
nodeGetPresentCPUBitmap(const char *sysfs_prefix)
|
||||||
{
|
{
|
||||||
int max_present;
|
int max_present;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
char *present_path = NULL;
|
char *present_path = NULL;
|
||||||
virBitmapPtr bitmap = NULL;
|
virBitmapPtr bitmap = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
|
||||||
|
|
||||||
if ((max_present = nodeGetCPUCount(NULL)) < 0)
|
if ((max_present = nodeGetCPUCount(prefix)) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
if (!(present_path = linuxGetCPUPresentPath(NULL)))
|
if (!(present_path = linuxGetCPUPresentPath(prefix)))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (virFileExists(present_path))
|
if (virFileExists(present_path))
|
||||||
bitmap = linuxParseCPUmap(max_present, present_path);
|
bitmap = linuxParseCPUmap(max_present, present_path);
|
||||||
|
@ -43,7 +43,7 @@ int nodeGetCellsFreeMemory(unsigned long long *freeMems,
|
|||||||
int nodeGetMemory(unsigned long long *mem,
|
int nodeGetMemory(unsigned long long *mem,
|
||||||
unsigned long long *freeMem);
|
unsigned long long *freeMem);
|
||||||
|
|
||||||
virBitmapPtr nodeGetPresentCPUBitmap(void);
|
virBitmapPtr nodeGetPresentCPUBitmap(const char *sysfs_prefix);
|
||||||
virBitmapPtr nodeGetCPUBitmap(int *max_id);
|
virBitmapPtr nodeGetCPUBitmap(int *max_id);
|
||||||
int nodeGetCPUCount(const char *sysfs_prefix);
|
int nodeGetCPUCount(const char *sysfs_prefix);
|
||||||
|
|
||||||
|
@ -3043,7 +3043,7 @@ virCgroupGetPercpuStats(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* To parse account file, we need to know how many cpus are present. */
|
/* To parse account file, we need to know how many cpus are present. */
|
||||||
if (!(cpumap = nodeGetPresentCPUBitmap()))
|
if (!(cpumap = nodeGetPresentCPUBitmap(NULL)))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
total_cpus = virBitmapSize(cpumap);
|
total_cpus = virBitmapSize(cpumap);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user