Factor out ram_save_blocks(), which will be used to send ram blocks hooked by save_page in ram_save_setup stage in coming patch.
Signed-off-by: Lei Li <li...@linux.vnet.ibm.com> --- arch_init.c | 25 +++++++++++++++---------- 1 files changed, 15 insertions(+), 10 deletions(-) diff --git a/arch_init.c b/arch_init.c index 1ea7c29..434a4ca 100644 --- a/arch_init.c +++ b/arch_init.c @@ -534,6 +534,20 @@ void acct_update_position(QEMUFile *f, size_t size, bool zero) } } +static void ram_save_blocks(QEMUFile *f) +{ + while (true) { + int bytes_sent; + + bytes_sent = ram_save_block(f, true); + /* no more blocks to sent */ + if (bytes_sent == 0) { + break; + } + bytes_transferred += bytes_sent; + } +} + static ram_addr_t ram_save_remaining(void) { return migration_dirty_pages; @@ -719,16 +733,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) /* try transferring iterative blocks of memory */ /* flush all remaining blocks regardless of rate limiting */ - while (true) { - int bytes_sent; - - bytes_sent = ram_save_block(f, true); - /* no more blocks to sent */ - if (bytes_sent == 0) { - break; - } - bytes_transferred += bytes_sent; - } + ram_save_blocks(f); ram_control_after_iterate(f, RAM_CONTROL_FINISH); migration_end(); -- 1.7.7.6