Skip to main content

capsid_protocol/
checkpoint.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{AttemptId, CheckpointId};
4
5#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
6#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
7pub enum Action {
8    Prepare {
9        checkpoint: CheckpointId,
10    },
11
12    // A restored guest keeps the clock of its capture until the host sets it.
13    Bind {
14        checkpoint: CheckpointId,
15
16        attempt: AttemptId,
17
18        realtime_ns: u64,
19
20        // The attempt belongs to another instance than the capture, so the
21        // guest takes a new machine identity.
22        #[serde(default)]
23        fork: bool,
24    },
25
26    Resume {
27        checkpoint: CheckpointId,
28    },
29
30    Cancel {
31        checkpoint: CheckpointId,
32    },
33}
34
35#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
36#[serde(rename_all = "snake_case")]
37pub enum Phase {
38    Preparing,
39
40    Quiesced,
41
42    Bound,
43
44    Running,
45}
46
47#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
48#[serde(deny_unknown_fields)]
49pub struct Status {
50    pub version: u32,
51
52    pub checkpoint: CheckpointId,
53
54    pub source_attempt: AttemptId,
55
56    pub attempt: AttemptId,
57
58    pub phase: Phase,
59}