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>
This commit is contained in:
Peter Xu 2017-05-12 12:17:39 +08:00 committed by Dr. David Alan Gilbert
parent cdece0467c
commit 99e15582de
3 changed files with 23 additions and 17 deletions

View file

@ -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);