From nobody Wed Feb 11 02:14:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547122056749848.3406359493158; Thu, 10 Jan 2019 04:07:36 -0800 (PST) Received: from localhost ([127.0.0.1]:53269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZ7X-0005cq-2z for importer@patchew.org; Thu, 10 Jan 2019 07:07:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZ1m-0001Cn-Cf for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:01:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghZ1l-00005q-2p for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:01:38 -0500 Received: from forwardcorp1g.cmail.yandex.net ([87.250.241.190]:46363) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghZ1k-0008SH-97 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:01:36 -0500 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1g.cmail.yandex.net (Yandex) with ESMTP id ECC6221871; Thu, 10 Jan 2019 15:01:27 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id WviXPHoP7T-1RJWaiA6; Thu, 10 Jan 2019 15:01:27 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:e1bb:a1a7:a235:d6b4]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id v4PGSBu40N-1Rhu3Msu; Thu, 10 Jan 2019 15:01:27 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1547121687; bh=1oiXi9X65LRpMZZGO8d9RrL5iqqnzvQMgCubrNWRDuE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Til0eaesXMH1MIET36mE2ll84tfMzrcqjTmzfFGA1XcWey/C5DFJwrAkqfjiu2bDu lp1P6Mc6ZRlXu1y2aKvYtKKS0Q3LIPdaVfpJrpoFtvFUf0sbLc/rjNHdGaZzDEdSFe 3/mAx6qoYi3gaHECGMndGiV+7BviIQ4JcBBOffAE= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Yury Kotov To: qemu-devel@nongnu.org, Eduardo Habkost , Igor Mammedov , Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier Date: Thu, 10 Jan 2019 15:01:17 +0300 Message-Id: <20190110120120.9943-2-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190110120120.9943-1-yury-kotov@yandex-team.ru> References: <20190110120120.9943-1-yury-kotov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.250.241.190 Subject: [Qemu-devel] [PATCH 1/4] migration: add RAMBlock's offset validation 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: wrfsh@yandex-team.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" RAM migration has a RAMBlock validation stage (flag RAM_SAVE_FLAG_MEM_SIZE). In this stage QEMU checks further information about RAMBlock: 1. Presence (by idstr), 2. Length (trying to resize, when differs), 3. Optional page size. This patch adds a check for RAMBlock's offset. Currently we check it during RAM pages loading - every RAM page has an offset in its header. But there i= s a case when we don't send RAM pages (see below). The following commits introduce a capability (ignore-external) to skip some RAM blocks from migration. In such case the migration stream contains only meta information about RAM blocks to validate them. So, the only way to che= ck block's offset is to send it explicitly. Signed-off-by: Yury Kotov --- migration/ram.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 7e7deec4d8..39629254e1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3171,6 +3171,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) if (migrate_postcopy_ram() && block->page_size !=3D qemu_host_page= _size) { qemu_put_be64(f, block->page_size); } + qemu_put_be64(f, block->offset); } =20 rcu_read_unlock(); @@ -4031,7 +4032,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) =20 seq_iter++; =20 - if (version_id !=3D 4) { + if (version_id < 4) { ret =3D -EINVAL; } =20 @@ -4132,6 +4133,16 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) ret =3D -EINVAL; } } + if (version_id >=3D 5) { + ram_addr_t offset; + offset =3D qemu_get_be64(f); + if (block->offset !=3D offset) { + error_report("Mismatched RAM block offset %s " + "%" PRId64 "!=3D %" PRId64, + id, offset, (uint64_t)block->offs= et); + ret =3D -EINVAL; + } + } ram_control_load_hook(f, RAM_CONTROL_BLOCK_REG, block->idstr); } else { @@ -4363,5 +4374,5 @@ static SaveVMHandlers savevm_ram_handlers =3D { void ram_mig_init(void) { qemu_mutex_init(&XBZRLE.lock); - register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, &ram_sta= te); + register_savevm_live(NULL, "ram", 0, 5, &savevm_ram_handlers, &ram_sta= te); } --=20 2.20.1