From patchwork Wed Feb 11 03:06:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Liang Z" X-Patchwork-Id: 438662 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id ED71E1401D0 for ; Wed, 11 Feb 2015 14:19:50 +1100 (AEDT) Received: from localhost ([::1]:42904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLNq8-0004SH-TS for incoming@patchwork.ozlabs.org; Tue, 10 Feb 2015 22:19:48 -0500 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 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 10 Feb 2015 19:15:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,555,1418112000"; d="scan'208";a="452911904" Received: from lil.sh.intel.com (HELO localhost) ([10.239.159.167]) by FMSMGA003.fm.intel.com with ESMTP; 10 Feb 2015 19:00:26 -0800 From: Liang Li To: qemu-devel@nongnu.org Date: Wed, 11 Feb 2015 11:06:21 +0800 Message-Id: <1423623986-590-8-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Cc: quintela@redhat.com, Liang Li , armbru@redhat.com, lcapitulino@redhat.com, Yang Zhang , amit.shah@redhat.com, dgilbert@redhat.com Subject: [Qemu-devel] [v5 07/12] migration: Split the function ram_save_page X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Split the function ram_save_page for code reuse purpose. Signed-off-by: Liang Li Signed-off-by: Yang Zhang Reviewed-by: Juan Quintela --- 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; + } } }