Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions crates/engram-host-agent/tests/blk_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ async fn read_off_runtime(device: &Arc<File>, offset: u64, len: usize) -> Vec<u8
.unwrap()
}

/// The chunks the source recorded as read cold, less the first chunk. The
/// kernel's partition scan reads the start of the device at a time of its
/// own (in a work item on newer kernels), and the source records that
/// read like a guest's.
fn guest_reads(source: &BlkSource) -> Vec<u32> {
let mut touched = source.touched();
touched.retain(|chunk| *chunk != 0);
touched
}

#[tokio::test]
#[ignore = "requires root and the ublk_drv module"]
async fn a_source_serves_the_manifest_and_records_the_chunks_read_cold() {
Expand All @@ -116,7 +126,7 @@ async fn a_source_serves_the_manifest_and_records_the_chunks_read_cold() {
read_off_runtime(&device, at, 4096).await,
image[at as usize..at as usize + 4096]
);
assert_eq!(source.touched(), vec![3]);
assert_eq!(guest_reads(&source), vec![3]);

// The copy's stream: the whole device, region by region, ascending.
for at in (0..CHUNKS * CHUNK).step_by(REGION as usize) {
Expand All @@ -126,7 +136,11 @@ async fn a_source_serves_the_manifest_and_records_the_chunks_read_cold() {
"region at {at}"
);
}
assert_eq!(source.touched(), vec![3], "the stream is not a guest read");
assert_eq!(
guest_reads(&source),
vec![3],
"the stream is not a guest read"
);

drop(device);
source.stop().await.unwrap();
Expand Down
8 changes: 7 additions & 1 deletion crates/engram-sandbox-firecracker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3309,8 +3309,14 @@ impl FirecrackerBackend {
if let Some(status) = handler.try_wait().map_err(|e| {
SandboxError::Snapshot(format!("check uffd handler: {e}"))
})? {
// The handler's log holds the only reason.
let log = read_tail(&jail_dir.join("uffd-handler.log"), 2048)
.await
.unwrap_or_default();
return Err(SandboxError::Snapshot(format!(
"uffd handler exited before the load ({status})"
"uffd handler exited before the load ({status}); \
handler log: {}",
log.trim().replace('\n', " | ")
)));
}
if uffd_uds.exists() && state_path.exists() {
Expand Down
Loading