migration/ram.c | 21 +++++++++++---------- tests/qtest/migration/file-tests.c | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-)
Snapshots made with mapped-ram and x-ignore-shared flags are
not parsed properly.
Co-authored-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Pawel Zmarzly <pzmarzly0@gmail.com>
---
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 *block, ram_addr_t length)
assert(block);
+ if (migrate_ignore_shared()) {
+ hwaddr addr = qemu_get_be64(f);
+ if (migrate_ram_is_ignored(block) &&
+ block->mr->addr != addr) {
+ error_report("Mismatched GPAs for block %s "
+ "%" PRId64 "!= %" 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 *block, ram_addr_t length)
return -EINVAL;
}
}
- if (migrate_ignore_shared()) {
- hwaddr addr = qemu_get_be64(f);
- if (migrate_ram_is_ignored(block) &&
- block->mr->addr != addr) {
- error_report("Mismatched GPAs for block %s "
- "%" PRId64 "!= %" PRId64, block->idstr,
- (uint64_t)addr, (uint64_t)block->mr->addr);
- return -EINVAL;
- }
- }
ret = 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/file-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(MigrationTestEnv *env)
test_multifd_file_mapped_ram_dio);
}
+static void test_precopy_file_mapped_ram_ignore_shared(void)
+{
+ g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
+ FILE_TEST_FILENAME);
+ MigrateCommon args = {
+ .connect_uri = uri,
+ .listen_uri = "defer",
+ .start = {
+ .caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true,
+ .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] = true,
+ },
+ };
+
+ test_file_common(&args, true);
+}
+
void migration_test_add_file(MigrationTestEnv *env)
{
tmpfs = env->tmpfs;
@@ -329,6 +345,8 @@ void migration_test_add_file(MigrationTestEnv *env)
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);
--
2.52.0
Pawel Zmarzly <pzmarzly0@gmail.com> writes: > Snapshots made with mapped-ram and x-ignore-shared flags are > not parsed properly. > I'd suggest some extra words to help people in the future (no need to resend, we can add it while merging): "The ignore-shared feature adds and extra field in the stream, which needs to be consumed on the destination side. Even though mapped-ram has a fixed header format, the ignore-shared is part of the "generic" stream infomation so the mapped-ram code is currently skipping that be64 read which incorrectly offsets every subsequent read from the stream. The current ignore-shared handling can simply be moved earlier in the code to encompass mapped-ram as well since the ignore-shared doubleword is the first one read when parsing the ramblock section of the stream." > Co-authored-by: Peter Xu <peterx@redhat.com> > Signed-off-by: Pawel Zmarzly <pzmarzly0@gmail.com> taking or leaving my additions: Reviewed-by: Fabiano Rosas <farosas@suse.de> @Peter, we can probably merge this and deal with the rest of the ignore-shared situation later, right?
On Wed, Nov 26, 2025 at 09:57:02AM -0300, Fabiano Rosas wrote: > Pawel Zmarzly <pzmarzly0@gmail.com> writes: > > > Snapshots made with mapped-ram and x-ignore-shared flags are > > not parsed properly. > > > > I'd suggest some extra words to help people in the future (no need to > resend, we can add it while merging): > > "The ignore-shared feature adds and extra field in the stream, which > needs to be consumed on the destination side. Even though mapped-ram has > a fixed header format, the ignore-shared is part of the "generic" stream > infomation so the mapped-ram code is currently skipping that be64 read > which incorrectly offsets every subsequent read from the stream. > > The current ignore-shared handling can simply be moved earlier in the > code to encompass mapped-ram as well since the ignore-shared doubleword > is the first one read when parsing the ramblock section of the stream." > > > Co-authored-by: Peter Xu <peterx@redhat.com> > > Signed-off-by: Pawel Zmarzly <pzmarzly0@gmail.com> > > taking or leaving my additions: > Reviewed-by: Fabiano Rosas <farosas@suse.de> > > @Peter, we can probably merge this and deal with the rest of the > ignore-shared situation later, right? Yes agreed. I queued this patch for -rc3 with Fabiano's update on the commit log, thanks! -- Peter Xu
© 2016 - 2025 Red Hat, Inc.