|
|
9ae3a8 |
From 24775aa5499bad8dea9c067908390c778b4ede6c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 18 Sep 2013 09:31:04 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 20/29] exec: Reduce ifdeffery around -mem-path
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1379496669-22778-4-git-send-email-armbru@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 54423
|
|
|
9ae3a8 |
O-Subject: [PATCH 7.0 qemu-kvm 3/8] exec: Reduce ifdeffery around -mem-path
|
|
|
9ae3a8 |
Bugzilla: 1009328
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Instead of spreading its ifdeffery everywhere, confine it to
|
|
|
9ae3a8 |
qemu_ram_alloc_from_ptr(). Everywhere else, simply test block->fd,
|
|
|
9ae3a8 |
which is non-negative exactly when block uses -mem-path.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
|
|
|
9ae3a8 |
Message-id: 1375276272-15988-4-git-send-email-armbru@redhat.com
|
|
|
9ae3a8 |
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
|
|
|
9ae3a8 |
(cherry picked from commit 3435f39513a104294b5e3bbf3612047028d25cfc)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
exec.c | 37 ++++++++++---------------------------
|
|
|
9ae3a8 |
include/exec/cpu-all.h | 2 --
|
|
|
9ae3a8 |
2 files changed, 10 insertions(+), 29 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
exec.c | 37 ++++++++++---------------------------
|
|
|
9ae3a8 |
include/exec/cpu-all.h | 2 --
|
|
|
9ae3a8 |
2 files changed, 10 insertions(+), 29 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/exec.c b/exec.c
|
|
|
9ae3a8 |
index ef8d311..32ed61c 100644
|
|
|
9ae3a8 |
--- a/exec.c
|
|
|
9ae3a8 |
+++ b/exec.c
|
|
|
9ae3a8 |
@@ -1045,6 +1045,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
size = TARGET_PAGE_ALIGN(size);
|
|
|
9ae3a8 |
new_block = g_malloc0(sizeof(*new_block));
|
|
|
9ae3a8 |
+ new_block->fd = -1;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* This assumes the iothread lock is taken here too. */
|
|
|
9ae3a8 |
qemu_mutex_lock_ramlist();
|
|
|
9ae3a8 |
@@ -1149,17 +1150,9 @@ void qemu_ram_free(ram_addr_t addr)
|
|
|
9ae3a8 |
;
|
|
|
9ae3a8 |
} else if (xen_enabled()) {
|
|
|
9ae3a8 |
xen_invalidate_map_cache_entry(block->host);
|
|
|
9ae3a8 |
- } else if (mem_path) {
|
|
|
9ae3a8 |
-#if defined (__linux__) && !defined(TARGET_S390X)
|
|
|
9ae3a8 |
- if (block->fd) {
|
|
|
9ae3a8 |
- munmap(block->host, block->length);
|
|
|
9ae3a8 |
- close(block->fd);
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- qemu_anon_ram_free(block->host, block->length);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-#else
|
|
|
9ae3a8 |
- abort();
|
|
|
9ae3a8 |
-#endif
|
|
|
9ae3a8 |
+ } else if (block->fd >= 0) {
|
|
|
9ae3a8 |
+ munmap(block->host, block->length);
|
|
|
9ae3a8 |
+ close(block->fd);
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
qemu_anon_ram_free(block->host, block->length);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1190,25 +1183,15 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
flags = MAP_FIXED;
|
|
|
9ae3a8 |
munmap(vaddr, length);
|
|
|
9ae3a8 |
- if (mem_path) {
|
|
|
9ae3a8 |
-#if defined(__linux__) && !defined(TARGET_S390X)
|
|
|
9ae3a8 |
- if (block->fd) {
|
|
|
9ae3a8 |
+ if (block->fd >= 0) {
|
|
|
9ae3a8 |
#ifdef MAP_POPULATE
|
|
|
9ae3a8 |
- flags |= mem_prealloc ? MAP_POPULATE | MAP_SHARED :
|
|
|
9ae3a8 |
- MAP_PRIVATE;
|
|
|
9ae3a8 |
+ flags |= mem_prealloc ? MAP_POPULATE | MAP_SHARED :
|
|
|
9ae3a8 |
+ MAP_PRIVATE;
|
|
|
9ae3a8 |
#else
|
|
|
9ae3a8 |
- flags |= MAP_PRIVATE;
|
|
|
9ae3a8 |
-#endif
|
|
|
9ae3a8 |
- area = mmap(vaddr, length, PROT_READ | PROT_WRITE,
|
|
|
9ae3a8 |
- flags, block->fd, offset);
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- flags |= MAP_PRIVATE | MAP_ANONYMOUS;
|
|
|
9ae3a8 |
- area = mmap(vaddr, length, PROT_READ | PROT_WRITE,
|
|
|
9ae3a8 |
- flags, -1, 0);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-#else
|
|
|
9ae3a8 |
- abort();
|
|
|
9ae3a8 |
+ flags |= MAP_PRIVATE;
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
+ area = mmap(vaddr, length, PROT_READ | PROT_WRITE,
|
|
|
9ae3a8 |
+ flags, block->fd, offset);
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
#if defined(TARGET_S390X) && defined(CONFIG_KVM)
|
|
|
9ae3a8 |
flags |= MAP_SHARED | MAP_ANONYMOUS;
|
|
|
9ae3a8 |
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
|
|
|
9ae3a8 |
index e9c3717..c369b25 100644
|
|
|
9ae3a8 |
--- a/include/exec/cpu-all.h
|
|
|
9ae3a8 |
+++ b/include/exec/cpu-all.h
|
|
|
9ae3a8 |
@@ -476,9 +476,7 @@ typedef struct RAMBlock {
|
|
|
9ae3a8 |
* Writes must take both locks.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
QTAILQ_ENTRY(RAMBlock) next;
|
|
|
9ae3a8 |
-#if defined(__linux__) && !defined(TARGET_S390X)
|
|
|
9ae3a8 |
int fd;
|
|
|
9ae3a8 |
-#endif
|
|
|
9ae3a8 |
} RAMBlock;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
typedef struct RAMList {
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|