block: vhdx: Switch VhdxDiskSync::new to BlockResult

Wrap VhdxError via BlockError::new(Io, e).with_op(Open). Update VMM
CreateFixedVhdxDiskSync error variant from VhdxError to BlockError.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-25 15:19:19 +01:00
committed by Bo Chen
parent 019aa52830
commit b8b32f5927
2 changed files with 8 additions and 5 deletions
+6 -3
View File
@@ -12,7 +12,8 @@ use vmm_sys_util::eventfd::EventFd;
use crate::async_io::{ use crate::async_io::{
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult, 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}; use crate::{AsyncAdaptor, BlockBackend, Error};
pub struct VhdxDiskSync { pub struct VhdxDiskSync {
@@ -28,9 +29,11 @@ pub struct VhdxDiskSync {
} }
impl VhdxDiskSync { impl VhdxDiskSync {
pub fn new(f: File) -> VhdxResult<Self> { pub fn new(f: File) -> BlockResult<Self> {
Ok(VhdxDiskSync { 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)
})?)),
}) })
} }
} }
+2 -2
View File
@@ -42,7 +42,7 @@ use block::raw_sync::RawFileDiskSync;
use block::vhdx_sync::VhdxDiskSync; use block::vhdx_sync::VhdxDiskSync;
use block::{ use block::{
ImageType, block_aio_is_supported, block_io_uring_is_supported, detect_image_type, 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")] #[cfg(feature = "io_uring")]
use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk}; use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk};
@@ -581,7 +581,7 @@ pub enum DeviceManagerError {
/// Failed to create FixedVhdxDiskSync /// Failed to create FixedVhdxDiskSync
#[error("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. /// Failed to add DMA mapping handler to virtio-mem device.
#[error("Failed to add DMA mapping handler to virtio-mem device")] #[error("Failed to add DMA mapping handler to virtio-mem device")]