From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLNlc-0004UT-6x for qemu-devel@nongnu.org; Tue, 10 Feb 2015 22:15:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLNla-0000XA-Et for qemu-devel@nongnu.org; Tue, 10 Feb 2015 22:15:07 -0500 Received: from mga11.intel.com ([192.55.52.93]:43143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLNla-0000UZ-9f for qemu-devel@nongnu.org; Tue, 10 Feb 2015 22:15:06 -0500 From: Liang Li Date: Wed, 11 Feb 2015 11:06:21 +0800 Message-Id: <1423623986-590-8-git-send-email-liang.z.li@intel.com> In-Reply-To: <1423623986-590-1-git-send-email-liang.z.li@intel.com> References: <1423623986-590-1-git-send-email-liang.z.li@intel.com> Subject: [Qemu-devel] [v5 07/12] migration: Split the function ram_save_page List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: quintela@redhat.com, Liang Li , armbru@redhat.com, lcapitulino@redhat.com, Yang Zhang , amit.shah@redhat.com, dgilbert@redhat.com Split the function ram_save_page for code reuse purpose. Signed-off-by: Liang Li Signed-off-by: Yang Zhang --- arch_init.c | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/arch_init.c b/arch_init.c index 66f4bc1..fe062db 100644 --- a/arch_init.c +++ b/arch_init.c @@ -681,12 +681,28 @@ static void migration_bitmap_sync(void) } } +static int save_zero_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset, + uint8_t *p, int cont) +{ + int bytes_sent = -1; + + if (is_zero_range(p, TARGET_PAGE_SIZE)) { + acct_info.dup_pages++; + bytes_sent = save_block_hdr(f, block, offset, cont, + RAM_SAVE_FLAG_COMPRESS); + qemu_put_byte(f, 0); + bytes_sent++; + } + + return bytes_sent; +} + /* * ram_save_page: Send the given page to the stream * * Returns: Number of bytes written. */ -static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset, +static int ram_save_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset, bool last_stage) { int bytes_sent; @@ -717,24 +733,23 @@ static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset, acct_info.dup_pages++; } } - } else if (is_zero_range(p, TARGET_PAGE_SIZE)) { - acct_info.dup_pages++; - bytes_sent = save_block_hdr(f, block, offset, cont, - RAM_SAVE_FLAG_COMPRESS); - qemu_put_byte(f, 0); - bytes_sent++; - /* Must let xbzrle know, otherwise a previous (now 0'd) cached - * page would be stale - */ - xbzrle_cache_zero_page(current_addr); - } else if (!ram_bulk_stage && migrate_use_xbzrle()) { - bytes_sent = save_xbzrle_page(f, &p, current_addr, block, - offset, cont, last_stage); - if (!last_stage) { - /* Can't send this cached data async, since the cache page - * might get updated before it gets to the wire + } else { + bytes_sent = save_zero_page(f, block, offset, p, cont); + if (bytes_sent > 0) { + + /* Must let xbzrle know, otherwise a previous (now 0'd) cached + * page would be stale */ - send_async = false; + xbzrle_cache_zero_page(current_addr); + } else if (!ram_bulk_stage && migrate_use_xbzrle()) { + bytes_sent = save_xbzrle_page(f, &p, current_addr, block, + offset, cont, last_stage); + if (!last_stage) { + /* Can't send this cached data async, since the cache page + * might get updated before it gets to the wire + */ + send_async = false; + } } } -- 1.9.1