]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hostmem-file: make available memory-backend-file on POSIX-based hosts
authorHikaru Nishida <hikarupsp@gmail.com>
Mon, 24 Sep 2018 12:32:05 +0000 (21:32 +0900)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 2 Oct 2018 17:09:13 +0000 (19:09 +0200)
Before this change, memory-backend-file object is valid for Linux hosts
only because hostmem-file.c is compiled only on Linux hosts.
However, other POSIX-based hosts (such as macOS) can support
memory-backend-file object in the same way as on Linux hosts.
This patch makes hostmem-file.c and related functions to be compiled on
all POSIX-based hosts to make available memory-backend-file on them.

Signed-off-by: Hikaru Nishida <hikarupsp@gmail.com>
Message-Id: <20180924123205.29651-1-hikarupsp@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
backends/Makefile.objs
backends/hostmem-file.c
exec.c
include/exec/memory.h
memory.c

index ad7c0325eda9b88c12fad54306165639f8569453..717fcbdae4715db128b0c3b97fa70b08de014d5d 100644 (file)
@@ -4,7 +4,7 @@ common-obj-$(CONFIG_POSIX) += rng-random.o
 common-obj-$(CONFIG_TPM) += tpm.o
 
 common-obj-y += hostmem.o hostmem-ram.o
-common-obj-$(CONFIG_LINUX) += hostmem-file.o
+common-obj-$(CONFIG_POSIX) += hostmem-file.o
 
 common-obj-y += cryptodev.o
 common-obj-y += cryptodev-builtin.o
index 2476dcb4359731e5347154dca52e28499611edc1..e64074954f470410dfa693d957b11c31ee7dd3e5 100644 (file)
@@ -51,7 +51,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
         error_setg(errp, "mem-path property not set");
         return;
     }
-#ifndef CONFIG_LINUX
+#ifndef CONFIG_POSIX
     error_setg(errp, "-mem-path not supported on this host");
 #else
     if (!host_memory_backend_mr_inited(backend)) {
diff --git a/exec.c b/exec.c
index 6826c8337d550a4a86dbaf96d1ca2d55e5b4dbf1..d0821e69aadaa4af9317ad36332ea570136c3f65 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -1734,7 +1734,7 @@ long qemu_getrampagesize(void)
 }
 #endif
 
-#ifdef __linux__
+#ifdef CONFIG_POSIX
 static int64_t get_file_size(int fd)
 {
     int64_t size = lseek(fd, 0, SEEK_END);
@@ -2230,7 +2230,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
     }
 }
 
-#ifdef __linux__
+#ifdef CONFIG_POSIX
 RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
                                  uint32_t ram_flags, int fd,
                                  Error **errp)
index eb4f2fb249c6219861237027e4870b86735ed242..e78a9a4f489ca90de2ce4271a3f2fbb7cdab1b5f 100644 (file)
@@ -633,7 +633,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
                                                        uint64_t length,
                                                        void *host),
                                        Error **errp);
-#ifdef __linux__
+#ifdef CONFIG_POSIX
 
 /**
  * memory_region_init_ram_from_file:  Initialize RAM memory region with a
index aceadb2bf8fc5669ddf30225240b371d7a752f57..f797d82dd13ca716c24dc60f4e83376d5b62b44a 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -1557,7 +1557,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
     }
 }
 
-#ifdef __linux__
+#ifdef CONFIG_POSIX
 void memory_region_init_ram_from_file(MemoryRegion *mr,
                                       struct Object *owner,
                                       const char *name,