From nobody Sat Nov 29 10:17:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1764159166; cv=none; d=zohomail.com; s=zohoarc; b=PhXs/MCSB8K3NP1N8/3f1bzopaWiNBpR9qTssumJd3uP+F/r8k2ooRuuIQS9Faw1F5I1qzRU8bdfixNMRQLnMqyKNsQzBlBTzE9X3TEH4O2IfMrgUNxs8BzTso3B7hwnYbL6zdjAZUJO2hcuymDwNrv1mVzMvGwktkpQSkftSiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764159166; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NjGlMxqmi4jFAS3XRyH9VgyPblT7jZzO2mgmFvDZU7Y=; b=bp30X8G19sd4/Zbq6Q2BtIxnLqZJXgEkKNUHpNLxR64OBTjK9WiWxuiEZkxsA8Lj7r3R4pPpvY0QvwoQVfWnX9kVwPybZrlirnplzvAI2M0fm8VsjjvZQSGjkJH2x9LotYlpN4jlc/tIGv7JXvY8gPeR8HIinl2ygc0JIOy23M4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764159166660990.7829270603303; Wed, 26 Nov 2025 04:12:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vOENz-0007sF-0V; Wed, 26 Nov 2025 07:12:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vOENx-0007r1-Rm for qemu-devel@nongnu.org; Wed, 26 Nov 2025 07:12:37 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vOENw-0002Aw-AN for qemu-devel@nongnu.org; Wed, 26 Nov 2025 07:12:37 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4775ae77516so62952455e9.1 for ; Wed, 26 Nov 2025 04:12:35 -0800 (PST) Received: from localhost ([109.76.183.78]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42cb7f2e5a3sm39923344f8f.6.2025.11.26.04.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 04:12:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764159155; x=1764763955; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=NjGlMxqmi4jFAS3XRyH9VgyPblT7jZzO2mgmFvDZU7Y=; b=AfGNNNIHomhMw8l8hen0cHFkGT2xmyexPKSu0lsg40GtJCaHPM+eTxtUy4OEVjMcYR YVL7A/d3WnSjFszyvdZ0yjpo67b++CaAka5+J0AIZl59GCmE2moUIxlydRabgoCYY0dJ xj64F4qf6CIzDM+UgQpcJAc/3LrGB0xcBrVGijJTO86ocupnn8FQJHQShtwSPBb1SiRb JoELJO0AdurtdrKrIZx5ybRFadJ3uDgU+Ihz+iG8jj1NXIsW3GxZpdMfXE3PlKfPgf6d AHrfPk7oSlWzHhPK3IZcGbRht3g/BH9ADdI6QgG4p1GrZ++D8bgryUWdquPDMy19jAsg zOOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764159155; x=1764763955; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NjGlMxqmi4jFAS3XRyH9VgyPblT7jZzO2mgmFvDZU7Y=; b=BC0HbNkbIcuAwhf1E6VxGISqAchamKFR/3Cc7I7uKfNeyF12pcv7ub25svt82sZRVX XJq41FUK1mn4R0Uoyc3gM0vI2x/mOxRBjC0uV32JP0V6Z7y1xbglKyQ4YMJyWhUS+v5j gZsKKqgN7bQOctW+8o+99Yk4Q/uwtNfXSnZaAF+n7ANadYcnVEueucvELxktFKetuTIY GSD7pZCHtIFX7PA53kq3tlcgavD263cVI1tsCu7dr58RqFkJ0vwZ9zbxSIS47ABeidmS mGCkdeT5hMcIgy3pb9sAT5ljt/n+vMdynR6q9pmkWuOUAbm7MZqfodX661ByH5RZd8ac 7TuA== X-Gm-Message-State: AOJu0Yy2kPfnwKIgvaLQu4xJQUJcXSzXVvyDcEM7we30c2eokh2kkmZ5 lQ1AeZhQvmdg3njc5ACEm80n/PIX4dywqa1Bk+m+ovaoybh/dLqAfbQllBXknTYzjmOprQ== X-Gm-Gg: ASbGncuTSIzZvyB1Ltaeux1XSodRhedbBcTVPynDBXe3k34+Jrh8CB3Q7spCTqFaOib c7AtVjKM0QasRIZdlgb4EFAld/sun2NIV6wfhQiJwErclFgcAiZ2XeHRGPN/1CmLbL/s72R+diC 98gKytx8sPeG0pNK2M2PEXRyR5/FDz45yzZOa93SGA5tFI9U7XFxuyK0I28XJIr2DpqKCHPpRV8 gNP1A9XqSEjSU9OmZoIcKVuUn/5AcecDHg+uSW0Zo1aTsD5Inv3O98zzckIwi+Cq9kZMFzxKBZx 0UfCJ2A8saD7DFr4dZ2Y03STdBt5iqbxGeP8nG9GltYv1SkEl/0GhD1kI7quE1gQ4c2v4i2fF8K FlKpNPupM0TY+xymjZt9JTxfyQd7NSeE8lwNrSXPjSBjb3YORhP0Jsd5DfeipRIR3grpliGINUO MtcTV7ouE= X-Google-Smtp-Source: AGHT+IESUI2vKM5vrFZpyegg9JqJzXIzC/4VtUcGAxnprIsf7pQscfSO9xyqdunNj5/tlhYm/6dFfg== X-Received: by 2002:a05:600c:19cd:b0:477:c37:2ea7 with SMTP id 5b1f17b1804b1-477c1115febmr143812655e9.21.1764159154409; Wed, 26 Nov 2025 04:12:34 -0800 (PST) From: Pawel Zmarzly To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de Subject: [PATCH v2] migration: fix parsing snapshots with x-ignore-shared flag Date: Wed, 26 Nov 2025 12:12:33 +0000 Message-ID: <20251126121233.542473-1-pzmarzly0@gmail.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=pzmarzly0@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1764159169146019200 Content-Type: text/plain; charset="utf-8" Snapshots made with mapped-ram and x-ignore-shared flags are not parsed properly. Co-authored-by: Peter Xu Signed-off-by: Pawel Zmarzly Reviewed-by: Fabiano Rosas --- migration/ram.c | 21 +++++++++++---------- tests/qtest/migration/file-tests.c | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 29f016cb25..7d024b88b5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4205,6 +4205,17 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *blo= ck, ram_addr_t length) =20 assert(block); =20 + if (migrate_ignore_shared()) { + hwaddr addr =3D qemu_get_be64(f); + if (migrate_ram_is_ignored(block) && + block->mr->addr !=3D addr) { + error_report("Mismatched GPAs for block %s " + "%" PRId64 "!=3D %" PRId64, block->idstr, + (uint64_t)addr, (uint64_t)block->mr->addr); + return -EINVAL; + } + } + if (migrate_mapped_ram()) { parse_ramblock_mapped_ram(f, block, length, &local_err); if (local_err) { @@ -4244,16 +4255,6 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *blo= ck, ram_addr_t length) return -EINVAL; } } - if (migrate_ignore_shared()) { - hwaddr addr =3D qemu_get_be64(f); - if (migrate_ram_is_ignored(block) && - block->mr->addr !=3D addr) { - error_report("Mismatched GPAs for block %s " - "%" PRId64 "!=3D %" PRId64, block->idstr, - (uint64_t)addr, (uint64_t)block->mr->addr); - return -EINVAL; - } - } ret =3D rdma_block_notification_handle(f, block->idstr); if (ret < 0) { qemu_file_set_error(f, ret); diff --git a/tests/qtest/migration/file-tests.c b/tests/qtest/migration/fil= e-tests.c index 4d78ce0855..c196a703ff 100644 --- a/tests/qtest/migration/file-tests.c +++ b/tests/qtest/migration/file-tests.c @@ -303,6 +303,22 @@ static void migration_test_add_file_smoke(MigrationTes= tEnv *env) test_multifd_file_mapped_ram_dio); } =20 +static void test_precopy_file_mapped_ram_ignore_shared(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, + FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start =3D { + .caps[MIGRATION_CAPABILITY_MAPPED_RAM] =3D true, + .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] =3D true, + }, + }; + + test_file_common(&args, true); +} + void migration_test_add_file(MigrationTestEnv *env) { tmpfs =3D env->tmpfs; @@ -329,6 +345,8 @@ void migration_test_add_file(MigrationTestEnv *env) =20 migration_test_add("/migration/multifd/file/mapped-ram", test_multifd_file_mapped_ram); + migration_test_add("/migration/multifd/file/mapped-ram/ignore-shared", + test_precopy_file_mapped_ram_ignore_shared); migration_test_add("/migration/multifd/file/mapped-ram/live", test_multifd_file_mapped_ram_live); =20 --=20 2.52.0