From: Lukas Straub <lukasstraub2@web.de>
To: Avihai Horon <avihaih@nvidia.com>
Cc: qemu-devel@nongnu.org, "Alex Williamson" <alex@shazbot.org>,
"Cédric Le Goater" <clg@redhat.com>,
"Peter Xu" <peterx@redhat.com>, "Fabiano Rosas" <farosas@suse.de>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Jason Herne" <jjherne@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"David Hildenbrand" <david@kernel.org>,
"Eric Farman" <farman@linux.ibm.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
"John Snow" <jsnow@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Maor Gottlieb" <maorg@nvidia.com>
Subject: Re: [PATCH v5 08/16] migration: Fail migration if switchover-ack is requested after switchover decision
Date: Tue, 7 Jul 2026 12:17:41 +0200 [thread overview]
Message-ID: <20260707121741.473c2175@penguin> (raw)
In-Reply-To: <20260706085211.13905-9-avihaih@nvidia.com>
[-- Attachment #1: Type: text/plain, Size: 4890 bytes --]
On Mon, 6 Jul 2026 11:52:03 +0300
Avihai Horon <avihaih@nvidia.com> wrote:
> 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>
For the COLO parts:
Reviewed-by: Lukas Straub <lukasstraub2@web.de>
Tested-by: Lukas Straub <lukasstraub2@web.de>
> ---
> migration/savevm.h | 4 ++--
> migration/colo.c | 6 +++++-
> migration/migration.c | 4 +++-
> migration/savevm.c | 19 ++++++++++++++++++-
> 4 files changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/migration/savevm.h b/migration/savevm.h
> index fb92d3bc85..415198423f 100644
> --- a/migration/savevm.h
> +++ b/migration/savevm.h
> @@ -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);
> diff --git a/migration/colo.c b/migration/colo.c
> index 0cef0f6b0e..0f30a5926f 100644
> --- a/migration/colo.c
> +++ b/migration/colo.c
> @@ -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.
> diff --git a/migration/migration.c b/migration/migration.c
> index 2b625da114..98603ee19c 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -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()) {
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 1f6e696c50..f654a1c563 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -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)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-07-07 10:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 8:51 [PATCH v5 00/16] Make switchover-ack re-usable and add VFIO precopy REINIT feature Avihai Horon
2026-07-06 8:51 ` [PATCH v5 01/16] migration: Propagate errors in migration_completion_precopy() Avihai Horon
2026-07-06 8:51 ` [PATCH v5 02/16] migration/ram: Use migration_bitmap_sync_precopy() for postcopy discard Avihai Horon
2026-07-06 8:51 ` [PATCH v5 03/16] migration: Run final save_query_pending at switchover Avihai Horon
2026-07-06 11:40 ` Cédric Le Goater
2026-07-07 10:16 ` Lukas Straub
2026-07-07 12:17 ` Cédric Le Goater
2026-07-08 14:19 ` Jason J. Herne
2026-07-06 8:51 ` [PATCH v5 04/16] migration: Log the approver in qemu_loadvm_approve_switchover() Avihai Horon
2026-07-06 8:52 ` [PATCH v5 05/16] migration: Replace switchover_ack_needed SaveVMHandler Avihai Horon
2026-07-06 8:52 ` [PATCH v5 06/16] migration: Rename switchover-ack code to legacy Avihai Horon
2026-07-06 8:52 ` [PATCH v5 07/16] migration: Make switchover-ack re-usable Avihai Horon
2026-07-07 10:17 ` Lukas Straub
2026-07-06 8:52 ` [PATCH v5 08/16] migration: Fail migration if switchover-ack is requested after switchover decision Avihai Horon
2026-07-07 10:17 ` Lukas Straub [this message]
2026-07-06 8:52 ` [PATCH v5 09/16] vfio/migration: Extract VFIO_MIG_FLAG_DEV_INIT_DATA_SENT sending to helper Avihai Horon
2026-07-06 8:52 ` [PATCH v5 10/16] vfio/migration: Add Error ** parameter to vfio_migration_init() Avihai Horon
2026-07-06 8:52 ` [PATCH v5 11/16] vfio/migration: Add new switchover-ack mechanism Avihai Horon
2026-07-06 8:52 ` [PATCH v5 12/16] vfio/migration: Implement VFIO_PRECOPY_INFO_REINIT feature Avihai Horon
2026-07-06 8:52 ` [PATCH v5 13/16] vfio/migration: Check VFIO_PRECOPY_INFO_REINIT during switchover Avihai Horon
2026-07-06 8:52 ` [PATCH v5 14/16] migration: Enable new switchover-ack Avihai Horon
2026-07-06 8:52 ` [PATCH v5 15/16] migration: Refactor migration_completion_precopy() to return bool Avihai Horon
2026-07-06 11:38 ` Cédric Le Goater
2026-07-06 8:52 ` [PATCH v5 16/16] migration: Fix "switchover" used as a verb in comments and docs Avihai Horon
2026-07-06 11:38 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260707121741.473c2175@penguin \
--to=lukasstraub2@web.de \
--cc=alex@shazbot.org \
--cc=armbru@redhat.com \
--cc=avihaih@nvidia.com \
--cc=borntraeger@linux.ibm.com \
--cc=clg@redhat.com \
--cc=cohuck@redhat.com \
--cc=david@kernel.org \
--cc=eblake@redhat.com \
--cc=farman@linux.ibm.com \
--cc=farosas@suse.de \
--cc=iii@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=jsnow@redhat.com \
--cc=maorg@nvidia.com \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=peterx@redhat.com \
--cc=philmd@mailo.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=vsementsov@yandex-team.ru \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.