mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +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
|
# nodeinfo.h
|
||||||
nodeCapsInitNUMA;
|
nodeCapsInitNUMA;
|
||||||
nodeGetCPUBitmap;
|
nodeGetCPUBitmap;
|
||||||
|
nodeGetCPUMap;
|
||||||
nodeGetCPUStats;
|
nodeGetCPUStats;
|
||||||
nodeGetCellsFreeMemory;
|
nodeGetCellsFreeMemory;
|
||||||
nodeGetFreeMemory;
|
nodeGetFreeMemory;
|
||||||
|
@ -1249,6 +1249,34 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
#endif
|
#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 HAVE_NUMACTL
|
||||||
# if LIBNUMA_API_VERSION <= 1
|
# if LIBNUMA_API_VERSION <= 1
|
||||||
# define NUMA_MAX_N_CPUS 4096
|
# define NUMA_MAX_N_CPUS 4096
|
||||||
|
@ -58,4 +58,10 @@ int nodeSetMemoryParameters(virConnectPtr conn,
|
|||||||
virTypedParameterPtr params,
|
virTypedParameterPtr params,
|
||||||
int nparams,
|
int nparams,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
|
int nodeGetCPUMap(virConnectPtr conn,
|
||||||
|
unsigned char **cpumap,
|
||||||
|
unsigned int *online,
|
||||||
|
unsigned int flags);
|
||||||
|
|
||||||
#endif /* __VIR_NODEINFO_H__*/
|
#endif /* __VIR_NODEINFO_H__*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user