mirror of https://github.com/xqemu/xqemu.git
Switch ram_save to the memory API
Avoid using ram_addr_t, instead use (MemoryRegion *, offset) pairs. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
7c63736603
commit
71c510e26e
34
arch_init.c
34
arch_init.c
|
@ -117,24 +117,22 @@ static int ram_save_block(QEMUFile *f)
|
||||||
{
|
{
|
||||||
RAMBlock *block = last_block;
|
RAMBlock *block = last_block;
|
||||||
ram_addr_t offset = last_offset;
|
ram_addr_t offset = last_offset;
|
||||||
ram_addr_t current_addr;
|
|
||||||
int bytes_sent = 0;
|
int bytes_sent = 0;
|
||||||
|
MemoryRegion *mr;
|
||||||
|
|
||||||
if (!block)
|
if (!block)
|
||||||
block = QLIST_FIRST(&ram_list.blocks);
|
block = QLIST_FIRST(&ram_list.blocks);
|
||||||
|
|
||||||
current_addr = block->offset + offset;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) {
|
mr = block->mr;
|
||||||
|
if (memory_region_get_dirty(mr, offset, DIRTY_MEMORY_MIGRATION)) {
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0;
|
int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0;
|
||||||
|
|
||||||
cpu_physical_memory_reset_dirty(current_addr,
|
memory_region_reset_dirty(mr, offset, TARGET_PAGE_SIZE,
|
||||||
current_addr + TARGET_PAGE_SIZE,
|
DIRTY_MEMORY_MIGRATION);
|
||||||
MIGRATION_DIRTY_FLAG);
|
|
||||||
|
|
||||||
p = block->host + offset;
|
p = memory_region_get_ram_ptr(mr) + offset;
|
||||||
|
|
||||||
if (is_dup_page(p, *p)) {
|
if (is_dup_page(p, *p)) {
|
||||||
qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_COMPRESS);
|
qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_COMPRESS);
|
||||||
|
@ -166,10 +164,7 @@ static int ram_save_block(QEMUFile *f)
|
||||||
if (!block)
|
if (!block)
|
||||||
block = QLIST_FIRST(&ram_list.blocks);
|
block = QLIST_FIRST(&ram_list.blocks);
|
||||||
}
|
}
|
||||||
|
} while (block != last_block || offset != last_offset);
|
||||||
current_addr = block->offset + offset;
|
|
||||||
|
|
||||||
} while (current_addr != last_block->offset + last_offset);
|
|
||||||
|
|
||||||
last_block = block;
|
last_block = block;
|
||||||
last_offset = offset;
|
last_offset = offset;
|
||||||
|
@ -186,9 +181,9 @@ static ram_addr_t ram_save_remaining(void)
|
||||||
|
|
||||||
QLIST_FOREACH(block, &ram_list.blocks, next) {
|
QLIST_FOREACH(block, &ram_list.blocks, next) {
|
||||||
ram_addr_t addr;
|
ram_addr_t addr;
|
||||||
for (addr = block->offset; addr < block->offset + block->length;
|
for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
|
||||||
addr += TARGET_PAGE_SIZE) {
|
if (memory_region_get_dirty(block->mr, addr,
|
||||||
if (cpu_physical_memory_get_dirty(addr, MIGRATION_DIRTY_FLAG)) {
|
DIRTY_MEMORY_MIGRATION)) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,11 +270,10 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
|
||||||
|
|
||||||
/* Make sure all dirty bits are set */
|
/* Make sure all dirty bits are set */
|
||||||
QLIST_FOREACH(block, &ram_list.blocks, next) {
|
QLIST_FOREACH(block, &ram_list.blocks, next) {
|
||||||
for (addr = block->offset; addr < block->offset + block->length;
|
for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
|
||||||
addr += TARGET_PAGE_SIZE) {
|
if (!memory_region_get_dirty(block->mr, addr,
|
||||||
if (!cpu_physical_memory_get_dirty(addr,
|
DIRTY_MEMORY_MIGRATION)) {
|
||||||
MIGRATION_DIRTY_FLAG)) {
|
memory_region_set_dirty(block->mr, addr);
|
||||||
cpu_physical_memory_set_dirty(addr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue