mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-12 04:58:32 +03:00
virhostmem: Handle numactl-less build in hugepages allocation/reporting
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@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
ebec3de97d
commit
78d4c12b8c
@ -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)"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user