mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:17 +00:00
migration: Fail migration if switchover-ack is requested after switchover decision
Switchover ACK is checked only during precopy while the guest is still running. The last migration_can_switchover() decision and guest stop are not atomic, so a device may want to request another switchover ACK in the gap after switchover decision has been made but before the guest is stopped. Migration would then miss that request, which can increase downtime. Cover this case by failing the migration if a switchover-ack was requested during that time. Ideally, precopy iterations should be resumed in this case, however, VFIO doesn't support going back to precopy after being stopped, so implementing such logic would require non-trivial changes to the guest start/stop flow. Given the above and that this case should be rare, failing the migration seems reasonable. Signed-off-by: Avihai Horon <avihaih@nvidia.com> Link: https://lore.kernel.org/qemu-devel/20260706085211.13905-9-avihaih@nvidia.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
committed by
Cédric Le Goater
parent
de0a1aed07
commit
8757d5155f
@@ -473,7 +473,11 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
|
||||
* state is saved. Unlike a regular switchover, COLO reaches completion
|
||||
* repeatedly for every checkpoint, so this must be done on each one.
|
||||
*/
|
||||
qemu_savevm_query_pending_final(s, &pending);
|
||||
if (!qemu_savevm_query_pending_final(s, &pending, &local_err)) {
|
||||
ret = -1;
|
||||
bql_unlock();
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Only save VM's live state, which not including device state.
|
||||
|
||||
@@ -2833,7 +2833,9 @@ static bool migration_switchover_start(MigrationState *s, Error **errp)
|
||||
* properly update all the dirty bitmaps to finally generate the
|
||||
* correct discard bitmaps; see ram_postcopy_send_discard_bitmap().
|
||||
*/
|
||||
qemu_savevm_query_pending_final(s, &pending);
|
||||
if (!qemu_savevm_query_pending_final(s, &pending, errp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Inactivate disks except in COLO */
|
||||
if (!migrate_colo()) {
|
||||
|
||||
@@ -1852,11 +1852,28 @@ void qemu_savevm_query_pending_iter(MigrationState *s, MigPendingData *pending,
|
||||
qemu_savevm_query_pending(s, pending, exact, false);
|
||||
}
|
||||
|
||||
void qemu_savevm_query_pending_final(MigrationState *s, MigPendingData *pending)
|
||||
bool qemu_savevm_query_pending_final(MigrationState *s, MigPendingData *pending,
|
||||
Error **errp)
|
||||
{
|
||||
g_assert(bql_locked());
|
||||
|
||||
qemu_savevm_query_pending(s, pending, true, true);
|
||||
|
||||
/*
|
||||
* Switchover-ack requests done after switchover decision are not allowed.
|
||||
* Fail the migration in this case since we currently don't support going
|
||||
* back to precopy.
|
||||
*/
|
||||
if (migrate_switchover_ack() && !migrate_switchover_ack_legacy() &&
|
||||
pending->switchover_ack_pending > 0) {
|
||||
error_setg(errp,
|
||||
"Switchover ACK was requested by %" PRIu32
|
||||
" devices during switchover",
|
||||
pending->switchover_ack_pending);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void qemu_savevm_state_cleanup(void)
|
||||
|
||||
@@ -47,8 +47,8 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f);
|
||||
int qemu_savevm_state_complete_precopy(MigrationState *s, Error **errp);
|
||||
void qemu_savevm_query_pending_iter(MigrationState *s, MigPendingData *pending,
|
||||
bool exact);
|
||||
void qemu_savevm_query_pending_final(MigrationState *s,
|
||||
MigPendingData *pending);
|
||||
bool qemu_savevm_query_pending_final(MigrationState *s,
|
||||
MigPendingData *pending, Error **errp);
|
||||
int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy);
|
||||
bool qemu_savevm_state_postcopy_prepare(QEMUFile *f, Error **errp);
|
||||
void qemu_savevm_state_end(QEMUFile *f);
|
||||
|
||||
Reference in New Issue
Block a user