提交 d34439c9 编写于 作者: V Viktor Mihajlovski 提交者: Eric Blake

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: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
上级 2f4c5338
...@@ -908,6 +908,7 @@ virNodeDeviceObjUnlock; ...@@ -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, ...@@ -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, ...@@ -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__*/
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册