[PATCH] virfile: relax checks for hugetlbfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are use cases where it is useful to use the support in libvirt
for file-backed guest memory, but without using hugetlbfs but tmpfs
instead (for example, to run tests on hosts that do not have hugepages
configured, or to use Linux's idle page tracking to monitor guest
memory accesses at a 4k page granularity.).

Drop the check for hugetlbfs when querying the huge page size, but
move it to the loop that's searching for a suitable mount to use.

Change-Id: I2c9589191e14653724725b944171689553ee6bae
---
 src/util/virfile.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 82cb36dbc..24ff5e208 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3438,19 +3438,23 @@ virFileGetHugepageSize(const char *path,
         goto cleanup;
     }
 
-    if (fs.f_type != HUGETLBFS_MAGIC) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("not a hugetlbfs mount: '%s'"),
-                       path);
-        goto cleanup;
-    }
-
     *size = fs.f_bsize / 1024; /* we are storing size in KiB */
     ret = 0;
  cleanup:
     return ret;
 }
 
+static bool
+virFileIsHugeTLBFS(const char *path)
+{
+    struct statfs fs;
+
+    if (statfs(path, &fs) < 0) {
+        return false;
+    }
+    return fs.f_type == HUGETLBFS_MAGIC;
+}
+
 # define PROC_MEMINFO "/proc/meminfo"
 # define HUGEPAGESIZE_STR "Hugepagesize:"
 
@@ -3517,6 +3521,9 @@ virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
         if (STRNEQ(mb.mnt_type, "hugetlbfs"))
             continue;
 
+        if (!virFileIsHugeTLBFS(mb.mnt_dir))
+            continue;
+
         if (VIR_EXPAND_N(fs, nfs, 1) < 0)
              goto cleanup;
 
-- 
2.11.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux