diff options
author | Jan Kiszka <jan.kiszka@web.de> | 2009-04-26 18:03:40 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-05-01 09:44:11 -0500 |
commit | 6f0437e8de95aebbd9e66af4d074c0d5119d86b7 (patch) | |
tree | d761a5e3bf4b2c4075415c3f880e65baf33856d8 /kvm-all.c | |
parent | 8563d5b31d1b1b43f3304ba59535b6b878c15a2d (diff) |
kvm: Avoid COW if KVM MMU is asynchronous
Avi Kivity wrote:
> Suggest wrapping in a function and hiding it deep inside kvm-all.c.
>
Done in v2:
---------->
If the KVM MMU is asynchronous (kernel does not support MMU_NOTIFIER),
we have to avoid COW for the guest memory. Otherwise we risk serious
breakage when guest pages change there physical locations due to COW
after fork. Seen when forking smbd during runtime via -smb.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'kvm-all.c')
-rw-r--r-- | kvm-all.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -773,6 +773,24 @@ int kvm_has_sync_mmu(void) return 0; } +void kvm_setup_guest_memory(void *start, size_t size) +{ + if (!kvm_has_sync_mmu()) { +#ifdef MADV_DONTFORK + int ret = madvise(start, size, MADV_DONTFORK); + + if (ret) { + perror("madvice"); + exit(1); + } +#else + fprintf(stderr, + "Need MADV_DONTFORK in absence of synchronous KVM MMU\n"); + exit(1); +#endif + } +} + #ifdef KVM_CAP_SET_GUEST_DEBUG struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env, target_ulong pc) |