Skip to content

Commit 398d6b9

Browse files
committed
enable specifying custom snapshot load path
Signed-off-by: Amory Hoste <[email protected]>
1 parent bd520b3 commit 398d6b9

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

src/devices/src/virtio/block/persist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub struct BlockState {
5757
)]
5858
cache_type: CacheTypeState,
5959
root_device: bool,
60-
disk_path: String,
60+
pub disk_path: String,
6161
virtio_state: VirtioDeviceState,
6262
rate_limiter_state: RateLimiterState,
6363
}

src/vmm/src/persist.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,18 @@ pub fn restore_from_snapshot(
418418
) -> std::result::Result<Arc<Mutex<Vmm>>, LoadSnapshotError> {
419419
use self::LoadSnapshotError::*;
420420
let track_dirty_pages = params.enable_diff_snapshots;
421-
let microvm_state = snapshot_state_from_file(&params.snapshot_path, version_map)?;
421+
let mut microvm_state = snapshot_state_from_file(&params.snapshot_path, version_map)?;
422+
423+
let new_snapshot_path = &params.new_snapshot_path;
424+
425+
if ! new_snapshot_path.eq("") {
426+
let n = microvm_state.device_states.block_devices.len();
427+
for i in 0..n {
428+
if microvm_state.device_states.block_devices[i].device_state.disk_path.contains("fc-dev-thinpool-") {
429+
microvm_state.device_states.block_devices[i].device_state.disk_path = new_snapshot_path.clone();
430+
}
431+
}
432+
}
422433

423434
// Some sanity checks before building the microvm.
424435
snapshot_state_sanity_check(&microvm_state)?;

src/vmm/src/vmm_config/snapshot.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ pub struct LoadSnapshotParams {
5050
pub mem_file_path: PathBuf,
5151
/// Setting this flag enables user page faults handling by a different process.
5252
pub enable_user_page_faults: bool,
53+
/// Setting this string to nonempty changes the snapshot device
54+
pub new_snapshot_path: String,
5355
/// Path to the passfd socket.
5456
pub sock_file_path: PathBuf,
5557
/// Setting this flag will enable KVM dirty page tracking and will

tools/devtool

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
# would help with reproducible builds (in addition to pinning Cargo.lock)
7070

7171
# Development container image (without tag)
72-
DEVCTR_IMAGE_NO_TAG="docker.io/vhiveease/fcuvm_dev"
72+
DEVCTR_IMAGE_NO_TAG="docker.io/amohoste/fcuvm_dev"
7373

7474
# Development container tag
7575
#DEVCTR_IMAGE_TAG="v30"

0 commit comments

Comments
 (0)