migration: fix parsing snapshots with x-ignore-shared flag
PATCH v2 1/1 migration: fix parsing snapshots with x-ignore-shared flag
Snapshots made with mapped-ram and x-ignore-shared flags are not parsed properly.
--- migration/ram.c | 21 +++++++++++---------- tests/qtest/migration/file-tests.c | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-)
migration/ram.c +11 -10
@@ -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);
tests/qtest/migration/file-tests.c +18 -0
@@ -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);
Signature · 1 line
2.52.0
Quoted 3 lines · Pawel Zmarzly
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."
Quoted 2 lines
Co-authored-by Peter Xu <[email protected]>Signed-off-by Pawel Zmarzly <[email protected]>
taking or leaving my additions:
@Peter, we can probably merge this and deal with the rest of the ignore-shared situation later, right?
Quoted 19 lines · Fabiano Rosas
Quoted 3 lines · Pawel Zmarzly
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."
Quoted 8 lines
Quoted 2 lines
Co-authored-by Peter Xu <[email protected]>Signed-off-by Pawel Zmarzly <[email protected]>taking or leaving my additions:
Reviewed-by Fabiano Rosas <[email protected]>@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!
Signature · 1 line
Peter Xu