From nobody Sat Feb 7 15:29:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531929003161638.7788292464469; Wed, 18 Jul 2018 08:50:03 -0700 (PDT) Received: from localhost ([::1]:37291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffoiI-0001Qr-4M for importer@patchew.org; Wed, 18 Jul 2018 11:50:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffoal-0003Ho-Jp for qemu-devel@nongnu.org; Wed, 18 Jul 2018 11:42:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffoag-0000HX-Hj for qemu-devel@nongnu.org; Wed, 18 Jul 2018 11:42:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:36402) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffoag-0000Fs-3E for qemu-devel@nongnu.org; Wed, 18 Jul 2018 11:42:10 -0400 Received: from vz-out.virtuozzo.com ([185.231.240.5] helo=dptest2.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1ffoae-0006bu-KH; Wed, 18 Jul 2018 18:42:08 +0300 From: Denis Plotnikov To: dgilbert@redhat.com, quintela@redhat.com, pbonzini@redhat.com Date: Wed, 18 Jul 2018 18:41:55 +0300 Message-Id: <20180718154200.26777-13-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180718154200.26777-1-dplotnikov@virtuozzo.com> References: <20180718154200.26777-1-dplotnikov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v1 12/17] ram: add background snapshot support in ram page saving part of migration 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: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Unify the function saving the ram pages for using in both the migration and the background snapshots. Signed-off-by: Denis Plotnikov --- migration/ram.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 10b6fdf23e..b1623e96e7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1803,11 +1803,28 @@ static int ram_find_and_save_block(RAMState *rs, bo= ol last_stage) if (!found) { /* priority queue empty, so just search for something dirty */ found =3D find_dirty_block(rs, &pss, &again); + + if (found && migrate_background_snapshot()) { + /* make a copy of the page and + * pass it to the page search status */ + int ret; + ret =3D ram_copy_page(pss.block, pss.page, &pss.page_copy); + if (ret =3D=3D 0) { + found =3D false; + pages =3D 0; + } else if (ret < 0) { + return ret; + } + } } =20 if (found) { pages =3D ram_save_host_page(rs, &pss, last_stage); } + + if (pss.page_copy) { + ram_page_buffer_decrease_used(); + } } while (!pages && again); =20 rs->last_seen_block =3D pss.block; --=20 2.17.0