From 3eb8c8e054707378daf40b02ac6f23cf001132f7 Mon Sep 17 00:00:00 2001 Message-Id: <3eb8c8e054707378daf40b02ac6f23cf001132f7@dist-git> From: Martin Kletzander Date: Thu, 15 Jan 2015 15:03:45 +0100 Subject: [PATCH] util: Add virNumaGetHostNodeset https://bugzilla.redhat.com/show_bug.cgi?id=1161540 That function tries its best to create a bitmap of host NUMA nodes. Signed-off-by: Martin Kletzander (cherry picked from commit d277d61420edf73f273338dcecf32d67009875f8) Signed-off-by: Martin Kletzander Signed-off-by: Jiri Denemark --- src/libvirt_private.syms | 1 + src/util/virnuma.c | 28 ++++++++++++++++++++++++++++ src/util/virnuma.h | 1 + 3 files changed, 30 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 62f4f08..325a912 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1717,6 +1717,7 @@ virNodeSuspendGetTargetMask; # util/virnuma.h virNumaGetAutoPlacementAdvice; virNumaGetDistances; +virNumaGetHostNodeset; virNumaGetMaxNode; virNumaGetNodeMemory; virNumaGetPageInfo; diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 1a34398..1b3280b 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -867,3 +867,31 @@ virNumaGetPages(int node ATTRIBUTE_UNUSED, return -1; } #endif /* #ifdef __linux__ */ + +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; +} diff --git a/src/util/virnuma.h b/src/util/virnuma.h index 13ebec6..9a6031f 100644 --- a/src/util/virnuma.h +++ b/src/util/virnuma.h @@ -34,6 +34,7 @@ char *virNumaGetAutoPlacementAdvice(unsigned short vcups, int virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune, virBitmapPtr nodemask); +virBitmapPtr virNumaGetHostNodeset(void); bool virNumaIsAvailable(void); int virNumaGetMaxNode(void); bool virNumaNodeIsAvailable(int node); -- 2.2.1