render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
639072
From 51034fde2272e6d7855433ac8ef79ffa59ac14a7 Mon Sep 17 00:00:00 2001
639072
Message-Id: <51034fde2272e6d7855433ac8ef79ffa59ac14a7@dist-git>
639072
From: Michal Privoznik <mprivozn@redhat.com>
639072
Date: Mon, 5 Sep 2022 10:34:44 +0200
639072
Subject: [PATCH] qemu_process: Don't require a hugetlbfs mount for memfd
639072
639072
The aim of qemuProcessNeedHugepagesPath() is to determine whether
639072
a hugetlbfs mount point is required for given domain (as in
639072
whether qemuBuildMemoryBackendProps() picks up
639072
memory-backend-file pointing to a hugetlbfs mount point). Well,
639072
when domain is configured to use memfd backend then that
639072
condition can never be true. Therefore, skip creating domain's
639072
private path under hugetlbfs mount points.
639072
639072
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
639072
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
639072
(cherry picked from commit f14f8dff9330ed51d817f190a2ee9ac76dfac00b)
639072
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2132176
639072
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
639072
---
639072
 src/qemu/qemu_process.c | 12 +++++++++++-
639072
 1 file changed, 11 insertions(+), 1 deletion(-)
639072
639072
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
639072
index 5c6657a876..540eee9ff0 100644
639072
--- a/src/qemu/qemu_process.c
639072
+++ b/src/qemu/qemu_process.c
639072
@@ -3810,8 +3810,18 @@ qemuProcessNeedHugepagesPath(virDomainDef *def,
639072
     const long system_pagesize = virGetSystemPageSizeKB();
639072
     size_t i;
639072
 
639072
-    if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE)
639072
+    switch ((virDomainMemorySource)def->mem.source) {
639072
+    case VIR_DOMAIN_MEMORY_SOURCE_FILE:
639072
+        /* This needs a hugetlbfs mount. */
639072
         return true;
639072
+    case VIR_DOMAIN_MEMORY_SOURCE_MEMFD:
639072
+        /* memfd works without a hugetlbfs mount */
639072
+        return false;
639072
+    case VIR_DOMAIN_MEMORY_SOURCE_NONE:
639072
+    case VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS:
639072
+    case VIR_DOMAIN_MEMORY_SOURCE_LAST:
639072
+        break;
639072
+    }
639072
 
639072
     for (i = 0; i < def->mem.nhugepages; i++) {
639072
         if (def->mem.hugepages[i].size != system_pagesize)
639072
-- 
639072
2.38.1
639072