mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
Remove uses of ram.last_offset (aka last_ram_offset)
We currently need this either to allocate the next ram_addr_t for a new block, or for total memory to be migrated. Both of which we can calculate without need of this to keep us in a contiguous address space. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
f292787d9a
commit
d17b5288d9
3 changed files with 30 additions and 13 deletions
19
exec.c
19
exec.c
|
@ -2767,6 +2767,17 @@ static void *file_ram_alloc(ram_addr_t memory, const char *path)
|
|||
}
|
||||
#endif
|
||||
|
||||
static ram_addr_t find_ram_offset(ram_addr_t size)
|
||||
{
|
||||
RAMBlock *block;
|
||||
ram_addr_t last = 0;
|
||||
|
||||
QLIST_FOREACH(block, &ram_list.blocks, next)
|
||||
last = MAX(last, block->offset + block->length);
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
ram_addr_t qemu_ram_alloc(ram_addr_t size)
|
||||
{
|
||||
RAMBlock *new_block;
|
||||
|
@ -2800,18 +2811,16 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)
|
|||
madvise(new_block->host, size, MADV_MERGEABLE);
|
||||
#endif
|
||||
}
|
||||
new_block->offset = ram_list.last_offset;
|
||||
new_block->offset = find_ram_offset(size);
|
||||
new_block->length = size;
|
||||
|
||||
QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next);
|
||||
|
||||
ram_list.phys_dirty = qemu_realloc(ram_list.phys_dirty,
|
||||
(ram_list.last_offset + size) >> TARGET_PAGE_BITS);
|
||||
memset(ram_list.phys_dirty + (ram_list.last_offset >> TARGET_PAGE_BITS),
|
||||
(new_block->offset + size) >> TARGET_PAGE_BITS);
|
||||
memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
|
||||
0xff, size >> TARGET_PAGE_BITS);
|
||||
|
||||
ram_list.last_offset += size;
|
||||
|
||||
if (kvm_enabled())
|
||||
kvm_setup_guest_memory(new_block->host, size);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue