Blame SOURCES/kvm-backends-hostmem-Fix-support-of-memory-backend-memfd.patch

bf143f
From 60da56e3685969493ae483c3cc2c66af13d00baf Mon Sep 17 00:00:00 2001
bf143f
From: Thomas Huth <thuth@redhat.com>
bf143f
Date: Wed, 10 Aug 2022 14:57:18 +0200
bf143f
Subject: [PATCH 1/3] backends/hostmem: Fix support of memory-backend-memfd in
bf143f
 qemu_maxrampagesize()
bf143f
MIME-Version: 1.0
bf143f
Content-Type: text/plain; charset=UTF-8
bf143f
Content-Transfer-Encoding: 8bit
bf143f
bf143f
RH-Author: Cédric Le Goater <None>
bf143f
RH-MergeRequest: 221: backends/hostmem: Fix support of memory-backend-memfd in qemu_maxrampagesize()
bf143f
RH-Bugzilla: 2117149
bf143f
RH-Acked-by: Thomas Huth <thuth@redhat.com>
bf143f
RH-Acked-by: David Hildenbrand <david@redhat.com>
bf143f
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
bf143f
RH-Commit: [1/1] b5a1047750af32c0a261b8385ea0e819eb16681a
bf143f
bf143f
It is currently not possible yet to use "memory-backend-memfd" on s390x
bf143f
with hugepages enabled. This problem is caused by qemu_maxrampagesize()
bf143f
not taking memory-backend-memfd objects into account yet, so the code
bf143f
in s390_memory_init() fails to enable the huge page support there via
bf143f
s390_set_max_pagesize(). Fix it by generalizing the code, so that it
bf143f
looks at qemu_ram_pagesize(memdev->mr.ram_block) instead of re-trying
bf143f
to get the information from the filesystem.
bf143f
bf143f
Suggested-by: David Hildenbrand <david@redhat.com>
bf143f
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2116496
bf143f
Message-Id: <20220810125720.3849835-2-thuth@redhat.com>
bf143f
Reviewed-by: David Hildenbrand <david@redhat.com>
bf143f
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
bf143f
Signed-off-by: Thomas Huth <thuth@redhat.com>
bf143f
(cherry picked from commit 8be934b70e923104da883b990dee18f02552d40e)
bf143f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2117149
bf143f
[clg: Resolved conflict on qemu_real_host_page_size() ]
bf143f
Signed-off-by: Cédric Le Goater <clg@redhat.com>
bf143f
---
bf143f
 backends/hostmem.c | 14 ++------------
bf143f
 1 file changed, 2 insertions(+), 12 deletions(-)
bf143f
bf143f
diff --git a/backends/hostmem.c b/backends/hostmem.c
bf143f
index 4c05862ed5..0c4654ea85 100644
bf143f
--- a/backends/hostmem.c
bf143f
+++ b/backends/hostmem.c
bf143f
@@ -305,22 +305,12 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
bf143f
     return backend->is_mapped;
bf143f
 }
bf143f
 
bf143f
-#ifdef __linux__
bf143f
 size_t host_memory_backend_pagesize(HostMemoryBackend *memdev)
bf143f
 {
bf143f
-    Object *obj = OBJECT(memdev);
bf143f
-    char *path = object_property_get_str(obj, "mem-path", NULL);
bf143f
-    size_t pagesize = qemu_mempath_getpagesize(path);
bf143f
-
bf143f
-    g_free(path);
bf143f
+    size_t pagesize = qemu_ram_pagesize(memdev->mr.ram_block);
bf143f
+    g_assert(pagesize >= qemu_real_host_page_size);
bf143f
     return pagesize;
bf143f
 }
bf143f
-#else
bf143f
-size_t host_memory_backend_pagesize(HostMemoryBackend *memdev)
bf143f
-{
bf143f
-    return qemu_real_host_page_size;
bf143f
-}
bf143f
-#endif
bf143f
 
bf143f
 static void
bf143f
 host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
bf143f
-- 
bf143f
2.35.3
bf143f