From: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
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(a)linux.vnet.ibm.com>
---
src/libvirt_private.syms | 1 +
src/nodeinfo.c | 28 ++++++++++++++++++++++++++++
src/nodeinfo.h | 6 ++++++
3 files changed, 35 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a9cae52..80bdf99 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -908,6 +908,7 @@ virNodeDeviceObjUnlock;
# nodeinfo.h
nodeCapsInitNUMA;
nodeGetCPUBitmap;
+nodeGetCPUMap;
nodeGetCPUStats;
nodeGetCellsFreeMemory;
nodeGetFreeMemory;
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 461b5dc..8b494df 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -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
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
index 73c6f51..44aa55d 100644
--- a/src/nodeinfo.h
+++ b/src/nodeinfo.h
@@ -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__*/
--
1.7.11.7