mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
virNodeGetCPUMap: Implement support function in nodeinfo
Added an implemention of virNodeGetCPUMap to nodeinfo.c, (nodeGetCPUMap) which can be used by all drivers for a Linux hypervisor host. Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
This commit is contained in:
parent
2f4c5338a6
commit
d34439c9e4
@ -908,6 +908,7 @@ virNodeDeviceObjUnlock;
|
||||
# nodeinfo.h
|
||||
nodeCapsInitNUMA;
|
||||
nodeGetCPUBitmap;
|
||||
nodeGetCPUMap;
|
||||
nodeGetCPUStats;
|
||||
nodeGetCellsFreeMemory;
|
||||
nodeGetFreeMemory;
|
||||
|
@ -1249,6 +1249,34 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
#endif
|
||||
}
|
||||
|
||||
int nodeGetCPUMap(virConnectPtr conn,
|
||||
unsigned char **cpumap,
|
||||
unsigned int *online,
|
||||
unsigned int flags)
|
||||
{
|
||||
virBitmapPtr cpus = NULL;
|
||||
int maxpresent;
|
||||
int ret = -1;
|
||||
int dummy;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (!(cpus = nodeGetCPUBitmap(conn, &maxpresent)))
|
||||
goto cleanup;
|
||||
|
||||
if (cpumap && virBitmapToData(cpus, cpumap, &dummy) < 0)
|
||||
goto cleanup;
|
||||
if (online)
|
||||
*online = virBitmapCountBits(cpus);
|
||||
|
||||
ret = maxpresent;
|
||||
cleanup:
|
||||
if (ret < 0 && cpumap)
|
||||
VIR_FREE(*cpumap);
|
||||
virBitmapFree(cpus);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if HAVE_NUMACTL
|
||||
# if LIBNUMA_API_VERSION <= 1
|
||||
# define NUMA_MAX_N_CPUS 4096
|
||||
|
@ -58,4 +58,10 @@ int nodeSetMemoryParameters(virConnectPtr conn,
|
||||
virTypedParameterPtr params,
|
||||
int nparams,
|
||||
unsigned int flags);
|
||||
|
||||
int nodeGetCPUMap(virConnectPtr conn,
|
||||
unsigned char **cpumap,
|
||||
unsigned int *online,
|
||||
unsigned int flags);
|
||||
|
||||
#endif /* __VIR_NODEINFO_H__*/
|
||||
|
Loading…
Reference in New Issue
Block a user