arch_init: Count the total number of pages by using helper function
authorzhanghailiang <zhang.zhanghailiang@huawei.com>
Mon, 9 Mar 2015 09:27:38 +0000 (17:27 +0800)
committerJuan Quintela <quintela@redhat.com>
Tue, 17 Mar 2015 14:20:37 +0000 (15:20 +0100)
There is already a helper function ram_bytes_total(), we can use it to
help counting the total number of pages used by ram blocks.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
arch_init.c

index c3f7d3f..fcfa328 100644 (file)
@@ -895,13 +895,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
      * Count the total number of pages used by ram blocks not including any
      * gaps due to alignment or unplugs.
      */
-    migration_dirty_pages = 0;
-    QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
-        uint64_t block_pages;
-
-        block_pages = block->used_length >> TARGET_PAGE_BITS;
-        migration_dirty_pages += block_pages;
-    }
+    migration_dirty_pages = ram_bytes_total() >> TARGET_PAGE_BITS;
 
     memory_global_dirty_log_start();
     migration_bitmap_sync();