]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Add virNumaGetHostNodeset
authorMartin Kletzander <mkletzan@redhat.com>
Sat, 13 Dec 2014 08:57:00 +0000 (09:57 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 16 Dec 2014 10:15:27 +0000 (11:15 +0100)
That function tries its best to create a bitmap of host NUMA nodes.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/libvirt_private.syms
src/util/virnuma.c
src/util/virnuma.h

index 5cd88956a625eeb329583c503603efd1c7c73dc3..363d847c7d8cadf3989a90c21bead54115923fd7 100644 (file)
@@ -1750,6 +1750,7 @@ virNodeSuspendGetTargetMask;
 # util/virnuma.h
 virNumaGetAutoPlacementAdvice;
 virNumaGetDistances;
+virNumaGetHostNodeset;
 virNumaGetMaxNode;
 virNumaGetNodeMemory;
 virNumaGetPageInfo;
index b8d76f4074b94cb8be857e3b26e3b4c846d75634..86564d4d41187a04b1cf2f09e844fb9bbe04c812 100644 (file)
@@ -983,3 +983,31 @@ virNumaNodesetIsAvailable(virBitmapPtr nodeset)
     }
     return true;
 }
+
+virBitmapPtr
+virNumaGetHostNodeset(void)
+{
+    int maxnode = virNumaGetMaxNode();
+    size_t i = 0;
+    virBitmapPtr nodeset = NULL;
+
+    if (maxnode < 0)
+        return NULL;
+
+    if (!(nodeset = virBitmapNew(maxnode + 1)))
+        return NULL;
+
+    for (i = 0; i <= maxnode; i++) {
+        if (!virNumaNodeIsAvailable(i))
+            continue;
+
+        if (virBitmapSetBit(nodeset, i) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Problem setting bit in bitmap"));
+            virBitmapFree(nodeset);
+            return NULL;
+        }
+    }
+
+    return nodeset;
+}
index 09034a274b9bd6e71309d74814139042124e7962..1f3c0ad8a75de51e85a1fecea9c5a0b2ab2fd4fa 100644 (file)
@@ -33,6 +33,7 @@ char *virNumaGetAutoPlacementAdvice(unsigned short vcups,
 int virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode,
                              virBitmapPtr nodeset);
 
+virBitmapPtr virNumaGetHostNodeset(void);
 bool virNumaNodesetIsAvailable(virBitmapPtr nodeset);
 bool virNumaIsAvailable(void);
 int virNumaGetMaxNode(void);