vmm: migration: Converge based on user-provided downtime and timeout

Wire the new `downtime_ms`, `timeout_s`, and `timeout_strategy` fields
from `VmSendMigrationData` into the precopy loop, replacing the previous
hard-coded 5-iteration cap.

Each iteration now evaluates three convergence criteria in order:
- no dirty pages remain;
- the estimated final-iteration downtime is within the configured budget
- or the overall migration timeout has elapsed.

On timeout, `TimeoutStrategy::Cancel` aborts and keeps the VM live on
the source, while `TimeoutStrategy::Force` proceeds regardless of the
downtime target. The convergence callback is updated to return a Result
to propagate the cancel error cleanly up the call stack.

With the recent changes [0], it is fairly easy to implement the new
checks and operate on actual metrics.

These changes are inspired by [1] but differ significantly in details.

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7799
[1] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7033

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2026-03-13 23:26:47 +01:00
committed by Rob Bradford
parent bbb0f083b0
commit 49e03c8bc5
2 changed files with 104 additions and 15 deletions

View File

@@ -40,9 +40,9 @@ pub struct MemoryMigrationContext {
///
/// Please note that this ignores any additional migration overhead and
/// only looks at the memory transfer itself.
estimated_downtime: Option<Duration>,
pub estimated_downtime: Option<Duration>,
/// Begin of the memory migration.
migration_begin: Instant,
pub migration_begin: Instant,
/// Duration of the memory migration.
///
/// This is only `None` until the last iteration is finished.