migration: Drop inactivate_disk param in qemu_savevm_state_complete*

This parameter is only used by one caller, which is the genuine precopy
complete path (migration_completion_precopy).

The parameter was introduced in a1fbe750fd ("migration: Fix race of image
locking between src and dst") to make sure the inactivate will happen
before EOF to make sure dest will always be able to activate the disk
properly.  However there's no limitation on how early we inactivate the
disk.  For precopy completion path, we can always do that as long as VM is
stopped.

Move the disk inactivate there, then we can remove this inactivate_disk
parameter in the whole call stack, because all the rest users pass in false
always.

Signed-off-by: Peter Xu <peterx@redhat.com>
Tested-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: https://lore.kernel.org/r/20250114230746.3268797-6-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
Peter Xu 2025-01-14 18:07:35 -05:00 committed by Fabiano Rosas
parent 812145fcf7
commit 4822128693
3 changed files with 23 additions and 31 deletions

View file

@ -2682,7 +2682,7 @@ static int postcopy_start(MigrationState *ms, Error **errp)
* Cause any non-postcopiable, but iterative devices to
* send out their final data.
*/
qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false);
qemu_savevm_state_complete_precopy(ms->to_dst_file, true);
/*
* in Finish migrate and with the io-lock held everything should
@ -2727,7 +2727,7 @@ static int postcopy_start(MigrationState *ms, Error **errp)
*/
qemu_savevm_send_postcopy_listen(fb);
qemu_savevm_state_complete_precopy(fb, false, false);
qemu_savevm_state_complete_precopy(fb, false);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(fb, 3);
}
@ -2859,11 +2859,21 @@ static int migration_completion_precopy(MigrationState *s,
goto out_unlock;
}
/* Inactivate disks except in COLO */
if (!migrate_colo()) {
/*
* Inactivate before sending QEMU_VM_EOF so that the
* bdrv_activate_all() on the other end won't fail.
*/
if (!migration_block_inactivate()) {
ret = -EFAULT;
goto out_unlock;
}
}
migration_rate_set(RATE_LIMIT_DISABLED);
/* Inactivate disks except in COLO */
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
!migrate_colo());
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false);
out_unlock:
bql_unlock();
return ret;
@ -3744,7 +3754,7 @@ static void *bg_migration_thread(void *opaque)
* save their state to channel-buffer along with devices.
*/
cpu_synchronize_all_states();
if (qemu_savevm_state_complete_precopy_non_iterable(fb, false, false)) {
if (qemu_savevm_state_complete_precopy_non_iterable(fb, false)) {
goto fail;
}
/*