Skip to content

Commit 4b6fe49

Browse files
committed
xxx
1 parent ccde23d commit 4b6fe49

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

vm-migration/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
44
//
55

6+
pub use progress::MigrationProgressAndStatus;
7+
68
use anyhow::anyhow;
79
use serde::{Deserialize, Serialize};
810
use thiserror::Error;
@@ -11,6 +13,8 @@ use crate::protocol::MemoryRangeTable;
1113

1214
mod bitpos_iterator;
1315
pub mod protocol;
16+
mod progress;
17+
1418

1519
#[derive(Error, Debug)]
1620
pub enum MigratableError {

vm-migration/src/progress.rs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright © 2025 Cyberus Technology GmbH
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
//! Module for reporting of the live-migration progress.
6+
7+
8+
/// Type holding the progress and status information of an ongoing live
9+
/// migration.
10+
///
11+
/// The states correspond to the [live-migration protocol].
12+
///
13+
/// [live-migration protocol]: super::protocol
14+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
15+
pub enum MigrationProgressAndStatus {
16+
/// The migration starts. Handshake and transfer of VM config.
17+
Starting {
18+
19+
},
20+
/// Transfer of VM memory in precopy mode.
21+
///
22+
/// Not used for local migrations.
23+
MemoryPrecopy {
24+
downtime_target_ms: u64,
25+
downtime_expected_ms: u64,
26+
/// The current memory iteration
27+
iteration: u64,
28+
memory_bytes_total: u64,
29+
memory_bytes_transmitted: u64,
30+
memory_4k_pages_transmitted: u64,
31+
memory_bytes_remaining_iteration: u64,
32+
memory_bytes_remaining_total: u64,
33+
},
34+
/// Transfer of VM memory in postcopy mode.
35+
///
36+
/// Not used for local migrations.
37+
MemoryPostcopy {
38+
39+
},
40+
41+
FinalState {
42+
43+
},
44+
Completed {
45+
46+
},
47+
Failed {
48+
49+
},
50+
Cancelled {
51+
52+
}
53+
}
54+
55+
#[cfg(test)]
56+
mod tests {
57+
use super::*;
58+
59+
#[test]
60+
fn print_json() {
61+
let starting = MigrationProgressAndStatus::Starting {
62+
63+
};
64+
let memory_precopy = MigrationProgressAndStatus::Memory {
65+
total_memory_b: 0,
66+
iteration: 0,
67+
};
68+
let memory_postcopy = MigrationProgressAndStatus::MemoryPostcopy {
69+
70+
};
71+
let finishing = MigrationProgressAndStatus::Completing {
72+
73+
};
74+
let completed = MigrationProgressAndStatus::Completed {
75+
76+
};
77+
let failed = MigrationProgressAndStatus::Failed {
78+
79+
};
80+
let cancelled = MigrationProgressAndStatus::Cancelled {
81+
82+
};
83+
84+
let vals = [
85+
starting, memory_precopy, memory_postcopy, finishing, completed, failed, cancelled ]
86+
;
87+
for val in vals {
88+
println!("{}", serde_json::to_string(&val).unwrap());
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)