Skip to content

Commit 8c97c5a

Browse files
xzpeterFabiano Rosas
authored andcommitted
migration/block: Fix possible race with block_inactive
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 <[email protected]> Reviewed-by: Fabiano Rosas <[email protected]> Message-Id: <[email protected]> Signed-off-by: Fabiano Rosas <[email protected]>
1 parent 61f2b48 commit 8c97c5a

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

migration/migration.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,14 +2742,11 @@ static int migration_completion_precopy(MigrationState *s,
27422742
goto out_unlock;
27432743
}
27442744

2745-
/*
2746-
* Inactivate disks except in COLO, and track that we have done so in order
2747-
* to remember to reactivate them if migration fails or is cancelled.
2748-
*/
2749-
s->block_inactive = !migrate_colo();
27502745
migration_rate_set(RATE_LIMIT_DISABLED);
2746+
2747+
/* Inactivate disks except in COLO */
27512748
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
2752-
s->block_inactive);
2749+
!migrate_colo());
27532750
out_unlock:
27542751
bql_unlock();
27552752
return ret;

migration/savevm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,8 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
15581558
qemu_file_set_error(f, ret);
15591559
return ret;
15601560
}
1561+
/* Remember that we did this */
1562+
s->block_inactive = true;
15611563
}
15621564
if (!in_postcopy) {
15631565
/* Postcopy stream will still be going */

0 commit comments

Comments
 (0)