diff --git a/block/src/fixed_vhd_async.rs b/block/src/fixed_vhd_async.rs index d54670315..e8b28c44c 100644 --- a/block/src/fixed_vhd_async.rs +++ b/block/src/fixed_vhd_async.rs @@ -26,7 +26,9 @@ impl FixedVhdDiskAsync { impl disk_file::DiskSize for FixedVhdDiskAsync { fn logical_size(&self) -> BlockResult { - Ok(self.0.logical_size().unwrap()) + self.0 + .logical_size() + .map_err(|e| BlockError::new(BlockErrorKind::Io, e)) } } @@ -69,13 +71,12 @@ impl disk_file::AsyncDiskFile for FixedVhdDiskAsync { } fn new_async_io(&self, ring_depth: u32) -> BlockResult> { + let size = self + .0 + .logical_size() + .map_err(|e| BlockError::new(BlockErrorKind::Io, e))?; Ok(Box::new( - FixedVhdAsync::new( - self.0.as_raw_fd(), - ring_depth, - self.0.logical_size().unwrap(), - ) - .map_err(|e| { + FixedVhdAsync::new(self.0.as_raw_fd(), ring_depth, size).map_err(|e| { BlockError::new(BlockErrorKind::Io, DiskFileError::NewAsyncIo(e)) .with_op(ErrorOp::Open) })?, diff --git a/block/src/fixed_vhd_sync.rs b/block/src/fixed_vhd_sync.rs index 877b17c1d..d7a578393 100644 --- a/block/src/fixed_vhd_sync.rs +++ b/block/src/fixed_vhd_sync.rs @@ -26,7 +26,9 @@ impl FixedVhdDiskSync { impl disk_file::DiskSize for FixedVhdDiskSync { fn logical_size(&self) -> BlockResult { - Ok(self.0.logical_size().unwrap()) + self.0 + .logical_size() + .map_err(|e| BlockError::new(BlockErrorKind::Io, e)) } } @@ -69,8 +71,12 @@ impl disk_file::AsyncDiskFile for FixedVhdDiskSync { } fn new_async_io(&self, _ring_depth: u32) -> BlockResult> { + let size = self + .0 + .logical_size() + .map_err(|e| BlockError::new(BlockErrorKind::Io, e))?; Ok(Box::new( - FixedVhdSync::new(self.0.as_raw_fd(), self.0.logical_size().unwrap()).map_err(|e| { + FixedVhdSync::new(self.0.as_raw_fd(), size).map_err(|e| { BlockError::new(BlockErrorKind::Io, DiskFileError::NewAsyncIo(e)) .with_op(ErrorOp::Open) })?,