]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBuildMemoryBackendProps: Prealloc mem for memfd backend
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 25 May 2020 12:35:51 +0000 (14:35 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Oct 2020 10:03:06 +0000 (12:03 +0200)
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 <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c

index 5c914b3999e96876fe3d6fbc4fc7b3e9f61c243c..c00b9e57e065970ee998122609c699280c09bf20 100644 (file)
@@ -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)