diff --git a/block/src/vhdx_sync.rs b/block/src/vhdx_sync.rs index 0a0dc47bc..a99f4f6f9 100644 --- a/block/src/vhdx_sync.rs +++ b/block/src/vhdx_sync.rs @@ -12,7 +12,8 @@ use vmm_sys_util::eventfd::EventFd; use crate::async_io::{ AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult, }; -use crate::vhdx::{Result as VhdxResult, Vhdx}; +use crate::error::{BlockError, BlockErrorKind, BlockResult, ErrorOp}; +use crate::vhdx::Vhdx; use crate::{AsyncAdaptor, BlockBackend, Error}; pub struct VhdxDiskSync { @@ -28,9 +29,11 @@ pub struct VhdxDiskSync { } impl VhdxDiskSync { - pub fn new(f: File) -> VhdxResult { + pub fn new(f: File) -> BlockResult { Ok(VhdxDiskSync { - vhdx_file: Arc::new(Mutex::new(Vhdx::new(f)?)), + vhdx_file: Arc::new(Mutex::new(Vhdx::new(f).map_err(|e| { + BlockError::new(BlockErrorKind::Io, e).with_op(ErrorOp::Open) + })?)), }) } } diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 4699d7231..4437cc8e9 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -42,7 +42,7 @@ use block::raw_sync::RawFileDiskSync; use block::vhdx_sync::VhdxDiskSync; use block::{ ImageType, block_aio_is_supported, block_io_uring_is_supported, detect_image_type, - open_disk_image, preallocate_disk, vhdx, + open_disk_image, preallocate_disk, }; #[cfg(feature = "io_uring")] use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk}; @@ -581,7 +581,7 @@ pub enum DeviceManagerError { /// Failed to create FixedVhdxDiskSync #[error("Failed to create FixedVhdxDiskSync")] - CreateFixedVhdxDiskSync(#[source] vhdx::VhdxError), + CreateFixedVhdxDiskSync(#[source] BlockError), /// Failed to add DMA mapping handler to virtio-mem device. #[error("Failed to add DMA mapping handler to virtio-mem device")]