diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-03-25 12:30:16 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-05-29 09:11:12 +0200 |
commit | 4ff87573df3606856a92c14eef3393a63d736d11 (patch) | |
tree | 17139888bbd5b87ad83af2fa2cbfc4f7de20ebac /memory.c | |
parent | 063143d5b1fde0fdcbae30bc7d6d14e76fa607d2 (diff) |
memory: remove qemu_get_ram_fd, qemu_set_ram_fd, qemu_ram_block_host_ptr
Remove direct uses of ram_addr_t and optimize memory_region_{get,set}_fd
now that a MemoryRegion knows its RAMBlock directly.
Reviewed-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'memory.c')
-rw-r--r-- | memory.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1626,13 +1626,26 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, int memory_region_get_fd(MemoryRegion *mr) { - if (mr->alias) { - return memory_region_get_fd(mr->alias); + int fd; + + rcu_read_lock(); + while (mr->alias) { + mr = mr->alias; } + fd = mr->ram_block->fd; + rcu_read_unlock(); - assert(mr->ram_block); + return fd; +} - return qemu_get_ram_fd(memory_region_get_ram_addr(mr)); +void memory_region_set_fd(MemoryRegion *mr, int fd) +{ + rcu_read_lock(); + while (mr->alias) { + mr = mr->alias; + } + mr->ram_block->fd = fd; + rcu_read_unlock(); } void *memory_region_get_ram_ptr(MemoryRegion *mr) |