From patchwork Tue Mar 27 09:10:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10312599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6959060212 for ; Wed, 28 Mar 2018 09:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64B5329177 for ; Wed, 28 Mar 2018 09:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56DCF29B88; Wed, 28 Mar 2018 09:20:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=2.0 tests=BAYES_00, DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DA62F29177 for ; Wed, 28 Mar 2018 09:20:39 +0000 (UTC) Received: from localhost ([::1]:38203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f17G3-0000na-3W for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Mar 2018 05:20:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f176Z-000132-7p for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f176U-00059f-J0 for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:51 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35815) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f176U-00059J-D1 for qemu-devel@nongnu.org; Wed, 28 Mar 2018 05:10:46 -0400 Received: by mail-pf0-x244.google.com with SMTP id u86so740662pfd.2 for ; Wed, 28 Mar 2018 02:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a4yJQ70gbcmr1a7GEjaWfWJaZjMnfyFa6mdz4JKGZqA=; b=mglAyVAjsravC+VR+USAPRf3Jabk4fGPO3Opva7Cm2f/xRw/U0BecIh7ET7ajt5Wfd U5Y5Xr/5nkdCKC3PizrMpHIOXomEjgGMomq8K+DJ1hBYdiFaE3m5VKO5Nkl5T8Qlc7m2 q4w9odSfBMBEJ9Z/dDspcaZ0tWQ8tMKvUthx6Vx0Ir6EkuiUAAdgOtstkvmjtOqxW0Pq 2xOHN3OfJ12hR/V1k3HbCetKKlDwS2kGy+YrZX6FIoXyZWqU/YtZn8nz7jSGE6V0KYzp ysRQcaJeL6KLB3OCe8VQtNx1QaghZPakvSw9cRDAeolxkFnUzHpqsgmkNDzle3fi56ew ISGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a4yJQ70gbcmr1a7GEjaWfWJaZjMnfyFa6mdz4JKGZqA=; b=AtGTnRTorjaaet0oPBELMCQ9LGiqB+kA7KtsTMBPNHMC7Mio1oFwd6sOrE0bw7Wa+6 cWvGi8JDBcTBqDGyYa75ivKwxZyRue+F3ZRKdkxmsHoeRLLgUvACLHNfxruk+2cW2Xqg WrfpT3GeNCMWKCSVQHu7sa7as8cwOlsh0IrmIqbFccJuM4yl5XTwmLRTBr23IpLw+CiD zRyvUCSYkdg/2rhNdK3Nea/miMcgRiuputt6YAC8O/t2Um8VQrMb2+/NZOleT2BXCFrI aPlYFBbEy+PihCtH3cvTggMBq/CoxutwiW5czEltV/PM5SMmZylqJ/9qJss9L5nN9jXX j0lw== X-Gm-Message-State: AElRT7GoCAWPqnbdKXPvVPovsftEQarsHC+Ux1H0YuWNqmujIhBWQa24 gSOPbmXlaZhVJU2G/ERz2Y4= X-Google-Smtp-Source: AIpwx48uGE6OcQ8KMF1K71QtRYYJhNpMjdmsVntrQAQcgdLI6TPfNs2jE2AVnLKAYV3VYfGfbsILAw== X-Received: by 10.101.101.133 with SMTP id u5mr1967153pgv.151.1522228245674; Wed, 28 Mar 2018 02:10:45 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.38]) by smtp.gmail.com with ESMTPSA id q9sm5590648pgs.89.2018.03.28.02.10.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Mar 2018 02:10:45 -0700 (PDT) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Date: Tue, 27 Mar 2018 17:10:40 +0800 Message-Id: <20180327091043.30220-8-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180327091043.30220-1-xiaoguangrong@tencent.com> References: <20180327091043.30220-1-xiaoguangrong@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 07/10] migration: move calling control_save_page to the common place X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Xiao Guangrong The function is called by both ram_save_page and ram_save_target_page, so move it to the common caller to cleanup the code Reviewed-by: Peter Xu Signed-off-by: Xiao Guangrong --- migration/ram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 104d3d3e9f..ce3ef4382d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1039,10 +1039,6 @@ static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) p = block->host + offset; trace_ram_save_page(block->idstr, (uint64_t)offset, p); - if (control_save_page(rs, block, offset, &pages)) { - return pages; - } - XBZRLE_cache_lock(); pages = save_zero_page(rs, block, offset); if (pages > 0) { @@ -1200,10 +1196,6 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss, p = block->host + offset; - if (control_save_page(rs, block, offset, &pages)) { - return pages; - } - /* When starting the process of a new block, the first page of * the block should be sent out before other pages in the same * block, and all the pages in last block should have been sent @@ -1491,6 +1483,14 @@ err: static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) { + RAMBlock *block = pss->block; + ram_addr_t offset = pss->page << TARGET_PAGE_BITS; + int res; + + if (control_save_page(rs, block, offset, &res)) { + return res; + } + /* * If xbzrle is on, stop using the data compression after first * round of migration even if compression is enabled. In theory,