From: Michael Ellerman Date: Tue, 17 Jul 2012 05:00:11 +0000 (+1000) Subject: kvm tools: Move mmap_anon_or_hugetblfs() into util X-Git-Tag: next-20120724~32^2~11^2~9 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1c22c0d9ec806eedc9d8f6175809dc46483b903a;p=karo-tx-linux.git kvm tools: Move mmap_anon_or_hugetblfs() into util So we can use it on powerpc. Acked-by: Matt Evans Signed-off-by: Michael Ellerman Signed-off-by: Pekka Enberg --- diff --git a/tools/kvm/include/kvm/util.h b/tools/kvm/include/kvm/util.h index dabf544c6d0c..3d1d9871244f 100644 --- a/tools/kvm/include/kvm/util.h +++ b/tools/kvm/include/kvm/util.h @@ -90,6 +90,6 @@ static inline void msleep(unsigned int msecs) usleep(MSECS_TO_USECS(msecs)); } -void *mmap_hugetlbfs(const char *htlbfs_path, u64 size); +void *mmap_anon_or_hugetlbfs(const char *hugetlbfs_path, u64 size); #endif /* KVM__UTIL_H */ diff --git a/tools/kvm/util/util.c b/tools/kvm/util/util.c index e7feebc929d9..a80cf86a2b50 100644 --- a/tools/kvm/util/util.c +++ b/tools/kvm/util/util.c @@ -113,3 +113,16 @@ void *mmap_hugetlbfs(const char *htlbfs_path, u64 size) return addr; } + +/* This function wraps the decision between hugetlbfs map (if requested) or normal mmap */ +void *mmap_anon_or_hugetlbfs(const char *hugetlbfs_path, u64 size) +{ + if (hugetlbfs_path) + /* + * We don't /need/ to map guest RAM from hugetlbfs, but we do so + * if the user specifies a hugetlbfs path. + */ + return mmap_hugetlbfs(hugetlbfs_path, size); + else + return mmap(NULL, size, PROT_RW, MAP_ANON_NORESERVE, -1, 0); +} diff --git a/tools/kvm/x86/kvm.c b/tools/kvm/x86/kvm.c index 10a1212431bd..8931639aaccc 100644 --- a/tools/kvm/x86/kvm.c +++ b/tools/kvm/x86/kvm.c @@ -128,19 +128,6 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) strcat(cmdline, " console=ttyS0 earlyprintk=serial i8042.noaux=1"); } -/* This function wraps the decision between hugetlbfs map (if requested) or normal mmap */ -static void *mmap_anon_or_hugetlbfs(const char *hugetlbfs_path, u64 size) -{ - if (hugetlbfs_path) - /* - * We don't /need/ to map guest RAM from hugetlbfs, but we do so - * if the user specifies a hugetlbfs path. - */ - return mmap_hugetlbfs(hugetlbfs_path, size); - else - return mmap(NULL, size, PROT_RW, MAP_ANON_NORESERVE, -1, 0); -} - /* Architecture-specific KVM init */ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) {