migration: add migration_guest_ram_loading() helper

Operations that read guest RAM (dump-guest-memory, memsave, pmemsave)
must refuse to run while the destination of a migration is still
receiving that RAM: during precopy it is incomplete, and during postcopy
a read faults the page in from the source. Provide a single predicate
they can share instead of open-coding the runstate and postcopy checks.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260619101834.228432-2-den@openvz.org>
This commit is contained in:
Denis V. Lunev
2026-06-19 12:18:28 +02:00
committed by Marc-André Lureau
parent 30e8a06b64
commit c2719f2514
2 changed files with 9 additions and 0 deletions

View File

@@ -117,6 +117,9 @@ void migration_file_set_error(int ret, Error *err);
/* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */
bool migration_in_incoming_postcopy(void);
/* True while the destination still receives guest RAM (precopy or postcopy) */
bool migration_guest_ram_loading(void);
/* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */
bool migration_incoming_postcopy_advised(void);

View File

@@ -1643,6 +1643,12 @@ bool migration_in_incoming_postcopy(void)
return ps >= POSTCOPY_INCOMING_DISCARD && ps < POSTCOPY_INCOMING_END;
}
bool migration_guest_ram_loading(void)
{
return runstate_check(RUN_STATE_INMIGRATE) ||
migration_in_incoming_postcopy();
}
bool migration_incoming_postcopy_advised(void)
{
PostcopyState ps = postcopy_state_get();