aboutsummaryrefslogtreecommitdiff
path: root/util/mmap-alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/mmap-alloc.c')
-rw-r--r--util/mmap-alloc.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
index 2fd8cbcc6f..fd329eccd8 100644
--- a/util/mmap-alloc.c
+++ b/util/mmap-alloc.c
@@ -50,19 +50,21 @@ size_t qemu_mempath_getpagesize(const char *mem_path)
struct statfs fs;
int ret;
- do {
- ret = statfs(mem_path, &fs);
- } while (ret != 0 && errno == EINTR);
-
- if (ret != 0) {
- fprintf(stderr, "Couldn't statfs() memory path: %s\n",
- strerror(errno));
- exit(1);
- }
+ if (mem_path) {
+ do {
+ ret = statfs(mem_path, &fs);
+ } while (ret != 0 && errno == EINTR);
- if (fs.f_type == HUGETLBFS_MAGIC) {
- /* It's hugepage, return the huge page size */
- return fs.f_bsize;
+ if (ret != 0) {
+ fprintf(stderr, "Couldn't statfs() memory path: %s\n",
+ strerror(errno));
+ exit(1);
+ }
+
+ if (fs.f_type == HUGETLBFS_MAGIC) {
+ /* It's hugepage, return the huge page size */
+ return fs.f_bsize;
+ }
}
#ifdef __sparc__
/* SPARC Linux needs greater alignment than the pagesize */