Skip to content

Commit 9e627a7

Browse files
roypatzulinx86
authored andcommitted
fix: do not panic if malformed snapshot file contains vhost devices
If a snapshot file is corrupted in a way that makes it _look_ like it contains a vhost-user-blk device, restoring will hit an `unimplemented!` inside `block::vhost_user/persist.rs`. So instead of using `unimplemented!`, just unconditionally return an error here. These errors are handled properly and cause Firecracker to exit gracefully instead. Signed-off-by: Patrick Roy <[email protected]>
1 parent e7a952e commit 9e627a7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/vmm/src/devices/virtio/block/vhost_user/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub const QUEUE_SIZE: u16 = 256;
1919
pub enum VhostUserBlockError {
2020
/// Cannot create config
2121
Config,
22-
/// Persistence error: {0}
23-
Persist(crate::devices::virtio::persist::PersistError),
22+
/// Snapshotting of vhost-user-blk devices is not supported
23+
SnapshottingNotSupported,
2424
/// Vhost-user error: {0}
2525
VhostUser(VhostUserError),
2626
/// Vhost error: {0}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ impl Persist<'_> for VhostUserBlock {
3838
_constructor_args: Self::ConstructorArgs,
3939
_state: &Self::State,
4040
) -> Result<Self, Self::Error> {
41-
unimplemented!("VhostUserBlock does not support snapshotting yet");
41+
Err(VhostUserBlockError::SnapshottingNotSupported)
4242
}
4343
}

0 commit comments

Comments
 (0)