Signed-off-by: Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> --- accel/kvm/kvm-all.c | 9 +++++++++ include/sysemu/kvm_int.h | 1 + 2 files changed, 10 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 0125c17edb..d336458e9e 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -138,6 +138,7 @@ struct KVMState QTAILQ_HEAD(, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE]; #endif KVMMemoryListener memory_listener; + KVMMemoryListener private_memory_listener; QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus; /* For "info mtree -f" to tell if an MR is registered in KVM */ @@ -359,6 +360,7 @@ static int kvm_set_user_memory_region(KVMMemoryListener *kml, KVMSlot *slot, boo mem.guest_phys_addr = slot->start_addr; mem.userspace_addr = (unsigned long)slot->ram; mem.flags = slot->flags; + mem.fd = slot->fd; if (slot->memory_size && !new && (mem.flags ^ slot->old_flags) & KVM_MEM_READONLY) { /* Set the slot size to 0 before setting the slot to the desired @@ -1423,6 +1425,9 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, mem->ram_start_offset = ram_start_offset; mem->ram = ram; mem->flags = kvm_mem_flags(mr); + if (mr->ram_block) { + mem->fd = mr->ram_block->fd; + } kvm_slot_init_dirty_bitmap(mem); err = kvm_set_user_memory_region(kml, mem, true); if (err) { @@ -2580,6 +2585,9 @@ static int kvm_init(MachineState *ms) kvm_memory_listener_register(s, &s->memory_listener, &address_space_memory, 0); + kvm_memory_listener_register(s, &s->private_memory_listener, + &address_space_private_memory, 2); + if (kvm_eventfds_allowed) { memory_listener_register(&kvm_io_listener, &address_space_io); @@ -2613,6 +2621,7 @@ err: close(s->fd); } g_free(s->memory_listener.slots); + g_free(s->private_memory_listener.slots); return ret; } diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index c788452cd9..0c11c63263 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -28,6 +28,7 @@ typedef struct KVMSlot int as_id; /* Cache of the offset in ram address space */ ram_addr_t ram_start_offset; + int fd; } KVMSlot; typedef struct KVMMemoryListener { -- 2.17.1