Skip to content

Commit a712043

Browse files
committed
fix(block): make prepare_save() more robust
If prepare_save() fails to drain the io_uring queues (when used) and sync the host filesystem we might end up with a corrupted disk snapshot. Currently, Firecracker ignores that, only emitting an error message. Be more strict and expect no errors, so that we can have a better post-mortem analysis of what happened. Signed-off-by: Babis Chalios <babis.chalios@e2b.dev>
1 parent 2639f85 commit a712043

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • src/vmm/src/devices/virtio/block/virtio

src/vmm/src/devices/virtio/block/virtio/device.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,9 +722,12 @@ impl VirtioBlock {
722722
}
723723

724724
fn drain_and_flush(&mut self, discard: bool) {
725-
if let Err(err) = self.disk.file_engine.drain_and_flush(discard) {
726-
error!("Failed to drain ops and flush block data: {:?}", err);
727-
}
725+
// If draining and/or flushing failed, hard crash to avoid continuing with a potentially
726+
// not consistent underlying filesystem in the disk.
727+
self.disk
728+
.file_engine
729+
.drain_and_flush(discard)
730+
.expect("virtio-block: failed to drain ops and flush block data");
728731
}
729732

730733
/// Prepare device for being snapshotted.

0 commit comments

Comments
 (0)