From 565b535de96ecbba11cf1b706c71b0a02f757237 Mon Sep 17 00:00:00 2001 From: Nicolas Viennot Date: Tue, 28 Dec 2021 23:47:20 +0000 Subject: [PATCH] error: show the file that failed to be served for better debugging Signed-off-by: Nicolas Viennot --- src/extract.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/extract.rs b/src/extract.rs index 62532aa2..fef6e12f 100644 --- a/src/extract.rs +++ b/src/extract.rs @@ -31,7 +31,7 @@ use crate::{ image_patcher::patch_img, }; use nix::poll::{poll, PollFd, PollFlags}; -use anyhow::Result; +use anyhow::{Result, Context}; // The serialized image is received via multiple data streams (`Shard`). The data streams are // comprised of markers followed by an optional data payload. The format of the markers is @@ -308,12 +308,13 @@ fn serve_img( while let Some(filename) = criu.read_next_file_request()? { match mem_store.remove(&filename) { Some(memory_file) => { - filenames_of_sent_files.insert(filename); + filenames_of_sent_files.insert(filename.clone()); criu.send_file_reply(true)?; // true means that the file exists. let mut pipe = criu.recv_pipe()?; // Try setting the pipe capacity. Failing is okay. let _ = pipe.set_capacity(CRIU_PIPE_DESIRED_CAPACITY); - memory_file.drain(&mut pipe)?; + memory_file.drain(&mut pipe) + .with_context(|| format!("while serving file {}", &filename))?; } None => { // If we keep the image file in our process, CRIU will also