From a658a4bdf721d37144841c212b0a0da15595f03f Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 25 May 2020 14:35:51 +0200 Subject: [PATCH] qemuBuildMemoryBackendProps: Prealloc mem for memfd backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a domain was using hugepages through memory-backend-file or via -mem-path, we would turn prealloc on. But we are not doing that for memory-backend-memfd. Fix this, because we need QEMU to fully allocate hugepages. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_command.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5c914b3999..c00b9e57e0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3098,10 +3098,13 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps, if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_MEMFD) { backendType = "memory-backend-memfd"; - if (useHugepage && - (virJSONValueObjectAdd(props, "b:hugetlb", useHugepage, NULL) < 0 || - virJSONValueObjectAdd(props, "U:hugetlbsize", pagesize << 10, NULL) < 0)) { - return -1; + if (useHugepage) { + if (virJSONValueObjectAdd(props, "b:hugetlb", useHugepage, NULL) < 0 || + virJSONValueObjectAdd(props, "U:hugetlbsize", pagesize << 10, NULL) < 0) { + return -1; + } + + prealloc = true; } if (qemuBuildMemoryBackendPropsShare(props, memAccess) < 0)