[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 43/58] kvm-all: drop kvm_setup_guest_memory
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 43/58] kvm-all: drop kvm_setup_guest_memory |
Date: |
Tue, 13 Sep 2016 19:16:14 +0200 |
From: Cao jin <address@hidden>
kvm_setup_guest_memory only does "madvise to QEMU_MADV_DONTFORK" and
is only called by ram_block_add, which actually is duplicate code.
Bonus: add simple comment for kvm_has_sync_mmu to make life easier.
Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Cao jin <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
exec.c | 4 +---
include/sysemu/kvm.h | 1 -
kvm-all.c | 15 +--------------
kvm-stub.c | 4 ----
4 files changed, 2 insertions(+), 22 deletions(-)
diff --git a/exec.c b/exec.c
index ce3fb9e..c81d5ab 100644
--- a/exec.c
+++ b/exec.c
@@ -1621,10 +1621,8 @@ static void ram_block_add(RAMBlock *new_block, Error
**errp)
if (new_block->host) {
qemu_ram_setup_dump(new_block->host, new_block->max_length);
qemu_madvise(new_block->host, new_block->max_length,
QEMU_MADV_HUGEPAGE);
+ /* MADV_DONTFORK is also needed by KVM in absence of synchronous MMU */
qemu_madvise(new_block->host, new_block->max_length,
QEMU_MADV_DONTFORK);
- if (kvm_enabled()) {
- kvm_setup_guest_memory(new_block->host, new_block->max_length);
- }
}
}
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index c9c2436..4938f65 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -221,7 +221,6 @@ int kvm_destroy_vcpu(CPUState *cpu);
#ifdef NEED_CPU_H
#include "cpu.h"
-void kvm_setup_guest_memory(void *start, size_t size);
void kvm_flush_coalesced_mmio_buffer(void);
int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr,
diff --git a/kvm-all.c b/kvm-all.c
index ebf35b0..8a4382e 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -2148,6 +2148,7 @@ void kvm_device_access(int fd, int group, uint64_t attr,
}
}
+/* Return 1 on success, 0 on failure */
int kvm_has_sync_mmu(void)
{
return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
@@ -2190,20 +2191,6 @@ int kvm_has_intx_set_mask(void)
return kvm_state->intx_set_mask;
}
-void kvm_setup_guest_memory(void *start, size_t size)
-{
- if (!kvm_has_sync_mmu()) {
- int ret = qemu_madvise(start, size, QEMU_MADV_DONTFORK);
-
- if (ret) {
- perror("qemu_madvise");
- fprintf(stderr,
- "Need MADV_DONTFORK in absence of synchronous KVM MMU\n");
- exit(1);
- }
- }
-}
-
#ifdef KVM_CAP_SET_GUEST_DEBUG
struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *cpu,
target_ulong pc)
diff --git a/kvm-stub.c b/kvm-stub.c
index 64e23f6..3227127 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -73,10 +73,6 @@ int kvm_has_many_ioeventfds(void)
return 0;
}
-void kvm_setup_guest_memory(void *start, size_t size)
-{
-}
-
int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
{
return -ENOSYS;
--
1.8.3.1
- [Qemu-devel] [PULL 31/58] MAINTAINERS: Fix wildcard for scsi headers, (continued)
- [Qemu-devel] [PULL 31/58] MAINTAINERS: Fix wildcard for scsi headers, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 32/58] MAINTAINERS: Add some header files to the PC chipset section, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 35/58] default-configs: removed obsolete CONFIG_ISA_MMIO, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 33/58] scsi: pvscsi: limit loop to fetch SG list, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 34/58] default-configs: remove CONFIG_PAM, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 38/58] sclpconsolelm: remove bogus check for -EAGAIN, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 37/58] ipmi: check return of qemu_chr_fe_write() for errors, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 40/58] char: convert qemu_chr_fe_write to qemu_chr_fe_write_all, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 39/58] hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_all, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 42/58] i8257: Make device "i8257" unavailable with -device, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 43/58] kvm-all: drop kvm_setup_guest_memory,
Paolo Bonzini <=
- [Qemu-devel] [PULL 41/58] Revert "megasas: remove useless check for cmd->frame", Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 36/58] default-configs: remove CONFIG_PIIX_PCI, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 45/58] atomics: Use __atomic_*_n() variant primitives, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 44/58] atomics: Remove redundant barrier()'s, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 46/58] checkpatch: Fix whitespace checks for documentation code blocks, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 47/58] optionrom: do not rely on compiler's bswap optimization, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 51/58] cutils: Remove SPLAT macro, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 54/58] cutils: Remove aarch64 buffer zero checking, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 49/58] ppc: do not redefine CPUPPCState, Paolo Bonzini, 2016/09/13
- [Qemu-devel] [PULL 53/58] cutils: Rearrange buffer_is_zero acceleration, Paolo Bonzini, 2016/09/13