On a Wednesday in 2022, Michal Privoznik wrote:
The qemuBuildMemoryGetPagesize() function has everything is needs
to decide whether preallocation is needed or not. Move the logic
from qemuBuildMemoryBackendProps() into
qemuBuildMemoryGetPagesize().
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 858aa0211a..9ab2b25fe2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3675,9 +3677,23 @@ qemuBuildMemoryGetPagesize(virQEMUDriverConfig *cfg,
return -1;
}
+ if (def->mem.allocation == VIR_DOMAIN_MEMORY_ALLOCATION_IMMEDIATE)
+ prealloc = true;
+
+ /* If the NVDIMM is a real device then there's nothing to prealloc.
+ * If anything, we would be only wearing off the device.
+ * Similarly, virtio-pmem-pci doesn't need prealloc either. */
+ if (mem->nvdimmPath && !mem->nvdimmPmem &&
+ mem->model != VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM)
+ prealloc = true;
+
+ if (useHugepage)
+ prealloc = true;
+
In the old location, the uses of if (useHugepage) were guarded by if
(!mem->nvdimmPath).
Please add the condition here as well.
Jano
*pagesizeRet = pagesize;
*needHugepageRet = needHugepage;
*useHugepageRet = useHugepage;
+ *preallocRet = prealloc;
return 0;
}