diff options
author | Peter Xu <peterx@redhat.com> | 2017-05-12 12:17:39 +0800 |
---|---|---|
committer | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2017-05-17 17:30:37 +0100 |
commit | 99e15582dea30d4a7c6fa5be9196d0f4d759231c (patch) | |
tree | 082f2e55209efa3bce4598cb427c60d9ff39e6db /migration | |
parent | cdece0467c00007cf8e3f4b3c3f0b13bf2c4fea9 (diff) |
ramblock: add RAMBLOCK_FOREACH()
So that it can simplifies the iterators.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <1494562661-9063-2-git-send-email-peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'migration')
-rw-r--r-- | migration/ram.c | 13 |
1 files changed, 7 insertions, 6 deletions
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); |