This functionality will be needed separately in a future patch. No functional change intended. Signed-off-by: Fuad Tabba <tabba@xxxxxxxxxx> --- util/util.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/util/util.c b/util/util.c index 22b64b6..e6c0951 100644 --- a/util/util.c +++ b/util/util.c @@ -81,13 +81,9 @@ void die_perror(const char *s) exit(1); } -static void *mmap_hugetlbfs(struct kvm *kvm, const char *htlbfs_path, u64 size) +static u64 get_hugepage_blk_size(const char *htlbfs_path) { - char mpath[PATH_MAX]; - int fd; struct statfs sfs; - void *addr; - unsigned long blk_size; if (statfs(htlbfs_path, &sfs) < 0) die("Can't stat %s\n", htlbfs_path); @@ -95,10 +91,20 @@ static void *mmap_hugetlbfs(struct kvm *kvm, const char *htlbfs_path, u64 size) if ((unsigned int)sfs.f_type != HUGETLBFS_MAGIC) die("%s is not hugetlbfs!\n", htlbfs_path); - blk_size = (unsigned long)sfs.f_bsize; - if (sfs.f_bsize == 0 || blk_size > size) { - die("Can't use hugetlbfs pagesize %ld for mem size %lld\n", - blk_size, (unsigned long long)size); + return sfs.f_bsize; +} + +static void *mmap_hugetlbfs(struct kvm *kvm, const char *htlbfs_path, u64 size) +{ + char mpath[PATH_MAX]; + int fd; + void *addr; + u64 blk_size; + + blk_size = get_hugepage_blk_size(htlbfs_path); + if (blk_size == 0 || blk_size > size) { + die("Can't use hugetlbfs pagesize %lld for mem size %lld\n", + (unsigned long long)blk_size, (unsigned long long)size); } kvm->ram_pagesize = blk_size; -- 2.38.1.431.g37b22c650d-goog