When using 'virsh freepages' or 'virsh allocpages' then
virHostMemGetFreePages() or virHostMemAllocPages() is called,
respectively. But the following may happen: libvirt was built
without numactl support and thus a fake NUMA node was constructed
for capabilities, which means that startCell is going to be 0.
But we can't blindly pass startCell = 0 to virNumaGetPageInfo()
nor virNumaSetPagePoolSize() because they would operate over node
specific path (/sys/devices/system/node/nodeX) rather than NUMA
agnostic path (/sys/kernel/mm/hugepages/) and we are not
guaranteed that the former exists (kernel might have been built
without NUMA support).
Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=1978574
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virhostmem.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c
index 8734dafb72..b13c3fe38e 100644
--- a/src/util/virhostmem.c
+++ b/src/util/virhostmem.c
@@ -849,6 +849,14 @@ virHostMemGetFreePages(unsigned int npages,
int cell;
size_t i, ncounts = 0;
+ if (!virNumaIsAvailable() && lastCell == 0 &&
+ startCell == 0 && cellCount == 1) {
+ /* As a special case, if we were built without numactl and want to
+ * fetch info on the fake NUMA node set startCell to -1 to make the
+ * loop below fetch overall info. */
+ startCell = -1;
+ }
+
if (startCell > lastCell) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("start cell %d out of range (0-%d)"),
@@ -891,6 +899,14 @@ virHostMemAllocPages(unsigned int npages,
int cell;
size_t i, ncounts = 0;
+ if (!virNumaIsAvailable() && lastCell == 0 &&
+ startCell == 0 && cellCount == 1) {
+ /* As a special case, if we were built without numactl and want to
+ * allocate hugepages on the fake NUMA node set startCell to -1 to make
+ * the loop below operate on NUMA agnostic sysfs paths. */
+ startCell = -1;
+ }
+
if (startCell > lastCell) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("start cell %d out of range (0-%d)"),
--
2.31.1