]> xenbits.xensource.com Git - libvirt.git/commitdiff
virNodeGetCPUMap: Implement support function in nodeinfo
authorViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Tue, 16 Oct 2012 14:05:14 +0000 (16:05 +0200)
committerEric Blake <eblake@redhat.com>
Thu, 25 Oct 2012 17:20:08 +0000 (11:20 -0600)
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>
src/libvirt_private.syms
src/nodeinfo.c
src/nodeinfo.h

index a9cae523d211aa91388f51deebd5e3bc3678d713..80bdf99b76768832184b180daa11f468d620e597 100644 (file)
@@ -908,6 +908,7 @@ virNodeDeviceObjUnlock;
 # nodeinfo.h
 nodeCapsInitNUMA;
 nodeGetCPUBitmap;
+nodeGetCPUMap;
 nodeGetCPUStats;
 nodeGetCellsFreeMemory;
 nodeGetFreeMemory;
index 461b5dc638862f7a260566dd37851f6943a6c500..8b494df524e5cebccf1cfa6761a4ca41899dc57f 100644 (file)
@@ -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
index 73c6f514c7829ddadd046581f76d635a4528031e..44aa55d289c33f9b8259ea18b47f4eb1d2bde472 100644 (file)
@@ -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__*/