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>
Denis V. Lunev committed
Jun 19, 2026 at 12:18 UTC
c2719f2514d768db5274d1ad2bafdc00d389b66d
2 files changed
+9
include/migration/misc.h
+3
@@ -117,6 +117,9 @@ void migration_file_set_error(int ret, Error *err);
117
/* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */
118
bool migration_in_incoming_postcopy(void);
119
120
+/* True while the destination still receives guest RAM (precopy or postcopy) */
121
+bool migration_guest_ram_loading(void);
122
+
123
/* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */
124
bool migration_incoming_postcopy_advised(void);
125
migration/migration.c
+6
@@ -1643,6 +1643,12 @@ bool migration_in_incoming_postcopy(void)
1643
return ps >= POSTCOPY_INCOMING_DISCARD && ps < POSTCOPY_INCOMING_END;
1644
}
1645
1646
+bool migration_guest_ram_loading(void)
1647
+{
1648
+ return runstate_check(RUN_STATE_INMIGRATE) ||
1649
+ migration_in_incoming_postcopy();
1650
+}
1651
+
1652
bool migration_incoming_postcopy_advised(void)
1653
{
1654
PostcopyState ps = postcopy_state_get();