From 99e15582dea30d4a7c6fa5be9196d0f4d759231c Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Fri, 12 May 2017 12:17:39 +0800 Subject: ramblock: add RAMBLOCK_FOREACH() So that it can simplifies the iterators. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <1494562661-9063-2-git-send-email-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/ram.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'migration/ram.c') diff --git a/migration/ram.c b/migration/ram.c index 293d27ce83..d88afeaddd 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -648,7 +648,7 @@ uint64_t ram_pagesize_summary(void) RAMBlock *block; uint64_t summary = 0; - QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + RAMBLOCK_FOREACH(block) { summary |= block->page_size; } @@ -676,7 +676,7 @@ static void migration_bitmap_sync(RAMState *rs) qemu_mutex_lock(&rs->bitmap_mutex); rcu_read_lock(); - QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + RAMBLOCK_FOREACH(block) { migration_bitmap_sync_range(rs, block, 0, block->used_length); } rcu_read_unlock(); @@ -1408,8 +1408,9 @@ uint64_t ram_bytes_total(void) uint64_t total = 0; rcu_read_lock(); - QLIST_FOREACH_RCU(block, &ram_list.blocks, next) + RAMBLOCK_FOREACH(block) { total += block->used_length; + } rcu_read_unlock(); return total; } @@ -1500,7 +1501,7 @@ void ram_postcopy_migrated_memory_release(MigrationState *ms) { struct RAMBlock *block; - QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + RAMBLOCK_FOREACH(block) { unsigned long *bitmap = block->bmap; unsigned long range = block->used_length >> TARGET_PAGE_BITS; unsigned long run_start = find_next_zero_bit(bitmap, range, 0); @@ -1578,7 +1579,7 @@ static int postcopy_each_ram_send_discard(MigrationState *ms) struct RAMBlock *block; int ret; - QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + RAMBLOCK_FOREACH(block) { PostcopyDiscardState *pds = postcopy_discard_send_init(ms, block->idstr); @@ -1961,7 +1962,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE); - QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + RAMBLOCK_FOREACH(block) { qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr)); qemu_put_be64(f, block->used_length); -- cgit v1.2.1