util: Add virNumaGetHostNodeset

That function tries its best to create a bitmap of host NUMA nodes.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2014-12-13 09:57:00 +01:00
parent 1a80b97ddf
commit d277d61420
3 changed files with 30 additions and 0 deletions

View File

@ -1750,6 +1750,7 @@ virNodeSuspendGetTargetMask;
# util/virnuma.h
virNumaGetAutoPlacementAdvice;
virNumaGetDistances;
virNumaGetHostNodeset;
virNumaGetMaxNode;
virNumaGetNodeMemory;
virNumaGetPageInfo;

View 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;
}

View 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);