[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/25] migration/block: Fix possible race with block_inactive
From: |
Fabiano Rosas |
Subject: |
[PULL 14/25] migration/block: Fix possible race with block_inactive |
Date: |
Fri, 10 Jan 2025 09:14:02 -0300 |
From: Peter Xu <peterx@redhat.com>
Src QEMU sets block_inactive=true very early before the invalidation takes
place. It means if something wrong happened during setting the flag but
before reaching qemu_savevm_state_complete_precopy_non_iterable() where it
did the invalidation work, it'll make block_inactive flag inconsistent.
For example, think about when qemu_savevm_state_complete_precopy_iterable()
can fail: it will have block_inactive set to true even if all block drives
are active.
Fix that by only update the flag after the invalidation is done.
No Fixes for any commit, because it's not an issue if bdrv_activate_all()
is re-entrant upon all-active disks - false positive block_inactive can
bring nothing more than "trying to active the blocks but they're already
active". However let's still do it right to avoid the inconsistent flag
v.s. reality.
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Message-Id: <20241206230838.1111496-6-peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/migration.c | 9 +++------
migration/savevm.c | 2 ++
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index c80fc7b94c..fd42a549e6 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2742,14 +2742,11 @@ static int migration_completion_precopy(MigrationState
*s,
goto out_unlock;
}
- /*
- * Inactivate disks except in COLO, and track that we have done so in order
- * to remember to reactivate them if migration fails or is cancelled.
- */
- s->block_inactive = !migrate_colo();
migration_rate_set(RATE_LIMIT_DISABLED);
+
+ /* Inactivate disks except in COLO */
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
- s->block_inactive);
+ !migrate_colo());
out_unlock:
bql_unlock();
return ret;
diff --git a/migration/savevm.c b/migration/savevm.c
index d4842b519d..3a414aff52 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1558,6 +1558,8 @@ int
qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
qemu_file_set_error(f, ret);
return ret;
}
+ /* Remember that we did this */
+ s->block_inactive = true;
}
if (!in_postcopy) {
/* Postcopy stream will still be going */
--
2.35.3
- [PULL 04/25] migration/ram: Move RAM_SAVE_FLAG* into ram.h, (continued)
- [PULL 04/25] migration/ram: Move RAM_SAVE_FLAG* into ram.h, Fabiano Rosas, 2025/01/10
- [PULL 05/25] migration/multifd: Unify RAM_SAVE_FLAG_MULTIFD_FLUSH messages, Fabiano Rosas, 2025/01/10
- [PULL 06/25] migration/multifd: Remove sync processing on postcopy, Fabiano Rosas, 2025/01/10
- [PULL 07/25] migration/multifd: Cleanup src flushes on condition check, Fabiano Rosas, 2025/01/10
- [PULL 08/25] migration/multifd: Document the reason to sync for save_setup(), Fabiano Rosas, 2025/01/10
- [PULL 09/25] migration/multifd: Fix compat with QEMU < 9.0, Fabiano Rosas, 2025/01/10
- [PULL 10/25] migration: Add helper to get target runstate, Fabiano Rosas, 2025/01/10
- [PULL 11/25] qmp/cont: Only activate disks if migration completed, Fabiano Rosas, 2025/01/10
- [PULL 12/25] migration/block: Make late-block-active the default, Fabiano Rosas, 2025/01/10
- [PULL 13/25] migration/block: Apply late-block-active behavior to postcopy, Fabiano Rosas, 2025/01/10
- [PULL 14/25] migration/block: Fix possible race with block_inactive,
Fabiano Rosas <=
- [PULL 15/25] migration/block: Rewrite disk activation, Fabiano Rosas, 2025/01/10
- [PULL 16/25] migration: Add more error handling to analyze-migration.py, Fabiano Rosas, 2025/01/10
- [PULL 17/25] migration: Remove unused argument in vmsd_desc_field_end, Fabiano Rosas, 2025/01/10
- [PULL 18/25] migration: Fix parsing of s390 stream, Fabiano Rosas, 2025/01/10
- [PULL 19/25] migration: Rename vmstate_info_nullptr, Fabiano Rosas, 2025/01/10
- [PULL 20/25] migration: Dump correct JSON format for nullptr replacement, Fabiano Rosas, 2025/01/10
- [PULL 21/25] migration: Fix arrays of pointers in JSON writer, Fabiano Rosas, 2025/01/10
- [PULL 22/25] s390x: Fix CSS migration, Fabiano Rosas, 2025/01/10
- [PULL 24/25] multifd: bugfix for incorrect migration data with QPL compression, Fabiano Rosas, 2025/01/10
- [PULL 25/25] multifd: bugfix for incorrect migration data with qatzip compression, Fabiano Rosas, 2025/01/10