Skip to content

Commit eff8a41

Browse files
committed
rename enable_diff_snapshots API paramter to track_dirty_pages
We have two different API parameters that do the same thing in two different APIs: For booted VMs, we enable KVM dirty page tracking by setting track_dirty_pages to true in /machine-config. For resumed VMs, we enable KVM dirty page tracking by setting enable_diff_snapshots to true in /snapshot/load. Apart from being inconsistent for no reason, one of these is very badly named: With support for diff snapshots without dirty page tracking, enable_diff_snapshots is a misnomer, because setting it to false will still allow us to do diff snapshots, it'll just fall back to mincore. Rename enable_diff_snapshots to track_dirty_pages, so we're consistent and also so that the parameter reflects what is actually happening. Go through the whole deprecation cycle of deprecating enable_diff_snapshots and adding the new track_dirty_pages parameter at the same time. We will need to remove enable_diff_snapshots in 2.0 Signed-off-by: Patrick Roy <[email protected]>
1 parent c7e5a51 commit eff8a41

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ and this project adheres to
2828

2929
### Deprecated
3030

31+
- [#????](...): Deprecated the `enable_diff_snapshots` parameter of the
32+
`/snapshot/load` API. Use `track_dirty_pages` instead.
33+
3134
### Removed
3235

3336
### Fixed

src/firecracker/src/api_server/request/snapshot.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use super::super::parsed_request::{ParsedRequest, RequestError};
1313
use super::super::request::{Body, Method, StatusCode};
1414

1515
/// Deprecation message for the `mem_file_path` field.
16-
const LOAD_DEPRECATION_MESSAGE: &str = "PUT /snapshot/load: mem_file_path field is deprecated.";
16+
const LOAD_DEPRECATION_MESSAGE: &str =
17+
"PUT /snapshot/load: mem_file_path and enable_diff_snapshots fields are deprecated.";
1718
/// None of the `mem_backend` or `mem_file_path` fields has been specified.
1819
pub const MISSING_FIELD: &str =
1920
"missing field: either `mem_backend` or `mem_file_path` is required";
@@ -80,7 +81,8 @@ fn parse_put_snapshot_load(body: &Body) -> Result<ParsedRequest, RequestError> {
8081
// Check for the presence of deprecated `mem_file_path` field and create
8182
// deprecation message if found.
8283
let mut deprecation_message = None;
83-
if snapshot_config.mem_file_path.is_some() {
84+
#[allow(deprecated)]
85+
if snapshot_config.mem_file_path.is_some() || snapshot_config.enable_diff_snapshots {
8486
// `mem_file_path` field in request is deprecated.
8587
METRICS.deprecated_api.deprecated_http_api_calls.inc();
8688
deprecation_message = Some(LOAD_DEPRECATION_MESSAGE);
@@ -103,7 +105,9 @@ fn parse_put_snapshot_load(body: &Body) -> Result<ParsedRequest, RequestError> {
103105
let snapshot_params = LoadSnapshotParams {
104106
snapshot_path: snapshot_config.snapshot_path,
105107
mem_backend,
106-
enable_diff_snapshots: snapshot_config.enable_diff_snapshots,
108+
#[allow(deprecated)]
109+
track_dirty_pages: snapshot_config.enable_diff_snapshots
110+
|| snapshot_config.track_dirty_pages,
107111
resume_vm: snapshot_config.resume_vm,
108112
network_overrides: snapshot_config.network_overrides,
109113
};
@@ -180,7 +184,7 @@ mod tests {
180184
backend_path: PathBuf::from("bar"),
181185
backend_type: MemBackendType::File,
182186
},
183-
enable_diff_snapshots: false,
187+
track_dirty_pages: false,
184188
resume_vm: false,
185189
network_overrides: vec![],
186190
};
@@ -210,7 +214,7 @@ mod tests {
210214
backend_path: PathBuf::from("bar"),
211215
backend_type: MemBackendType::File,
212216
},
213-
enable_diff_snapshots: true,
217+
track_dirty_pages: false,
214218
resume_vm: false,
215219
network_overrides: vec![],
216220
};
@@ -240,7 +244,7 @@ mod tests {
240244
backend_path: PathBuf::from("bar"),
241245
backend_type: MemBackendType::Uffd,
242246
},
243-
enable_diff_snapshots: false,
247+
track_dirty_pages: false,
244248
resume_vm: true,
245249
network_overrides: vec![],
246250
};
@@ -276,7 +280,7 @@ mod tests {
276280
backend_path: PathBuf::from("bar"),
277281
backend_type: MemBackendType::Uffd,
278282
},
279-
enable_diff_snapshots: false,
283+
track_dirty_pages: false,
280284
resume_vm: true,
281285
network_overrides: vec![NetworkOverride {
282286
iface_id: String::from("eth0"),
@@ -306,7 +310,7 @@ mod tests {
306310
backend_path: PathBuf::from("bar"),
307311
backend_type: MemBackendType::File,
308312
},
309-
enable_diff_snapshots: false,
313+
track_dirty_pages: false,
310314
resume_vm: true,
311315
network_overrides: vec![],
312316
};

src/firecracker/swagger/firecracker.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,11 @@ definitions:
12451245
enable_diff_snapshots:
12461246
type: boolean
12471247
description:
1248-
Enable support for incremental (diff) snapshots by tracking dirty guest pages.
1248+
(Deprecated) Enable dirty page tracking to improve space efficiency of diff snapshots
1249+
track_dirty_pages:
1250+
type: boolean
1251+
description:
1252+
Enable dirty page tracking to improve space efficiency of diff snapshots
12491253
mem_file_path:
12501254
type: string
12511255
description:

src/vmm/src/persist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub fn restore_from_snapshot(
347347
return Err(SnapshotStateFromFileError::UnknownNetworkDevice.into());
348348
}
349349
}
350-
let track_dirty_pages = params.enable_diff_snapshots;
350+
let track_dirty_pages = params.track_dirty_pages;
351351

352352
let vcpu_count = microvm_state
353353
.vcpu_states

src/vmm/src/rpc_interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ mod tests {
12491249
backend_type: MemBackendType::File,
12501250
backend_path: PathBuf::new(),
12511251
},
1252-
enable_diff_snapshots: false,
1252+
track_dirty_pages: false,
12531253
resume_vm: false,
12541254
network_overrides: vec![],
12551255
},

src/vmm/src/vmm_config/snapshot.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ pub struct LoadSnapshotParams {
6464
pub snapshot_path: PathBuf,
6565
/// Specifies guest memory backend configuration.
6666
pub mem_backend: MemBackendConfig,
67-
/// Setting this flag will enable KVM dirty page tracking and will
68-
/// allow taking subsequent incremental snapshots.
69-
pub enable_diff_snapshots: bool,
67+
/// Whether KVM dirty page tracking should be abled, to space optimization
68+
/// of differential snapshots.
69+
pub track_dirty_pages: bool,
7070
/// When set to true, the vm is also resumed if the snapshot load
7171
/// is successful.
7272
pub resume_vm: bool,
@@ -90,7 +90,10 @@ pub struct LoadSnapshotConfig {
9090
pub mem_backend: Option<MemBackendConfig>,
9191
/// Whether or not to enable KVM dirty page tracking.
9292
#[serde(default)]
93+
#[deprecated]
9394
pub enable_diff_snapshots: bool,
95+
/// Whether KVM dirty page tracking should be enabled.
96+
pub track_dirty_pages: bool,
9497
/// Whether or not to resume the vm post snapshot load.
9598
#[serde(default)]
9699
pub resume_vm: bool,

0 commit comments

Comments
 (0)