diff options
Diffstat (limited to 'src/libvirt.rs')
-rw-r--r-- | src/libvirt.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libvirt.rs b/src/libvirt.rs index 403dc45..c262444 100644 --- a/src/libvirt.rs +++ b/src/libvirt.rs @@ -2,7 +2,7 @@ use crate::util::wait_for_ssh; use log::debug; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::thread; use std::time::Duration; use virt::connect::Connect; @@ -52,6 +52,10 @@ pub enum VirtError { #[error("couldn't set domain {0} to be autostarted")] Autostart(String, #[source] virt::error::Error), + /// Failed to delete image file. + #[error("failed to delete image file {0}")] + DeleteImage(PathBuf, #[source] std::io::Error), + /// Error doing I/O. #[error(transparent)] IoError(#[from] std::io::Error), @@ -175,7 +179,8 @@ impl Libvirt { .map_err(|err| VirtError::Undefine(name.to_string(), err))?; debug!("removing image file {}", image.display()); - std::fs::remove_file(image)?; + std::fs::remove_file(image) + .map_err(|e| VirtError::DeleteImage(image.to_path_buf(), e))?; } Ok(()) |