thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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