block: vhd: Switch FixedVhdDiskAsync::new to BlockResult

Map FixedVhd::new io::Error to BlockError with ErrorOp::Open.
Update vmm CreateFixedVhdDiskAsync source type accordingly.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-24 17:01:55 +01:00
committed by Bo Chen
parent 38eb10d209
commit 15073edf08
2 changed files with 6 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ use vmm_sys_util::eventfd::EventFd;
use crate::async_io::{
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
};
use crate::error::{BlockError, BlockResult, ErrorOp};
use crate::fixed_vhd::FixedVhd;
use crate::raw_async::RawFileAsync;
use crate::{BatchRequest, BlockBackend};
@@ -17,8 +18,10 @@ use crate::{BatchRequest, BlockBackend};
pub struct FixedVhdDiskAsync(FixedVhd);
impl FixedVhdDiskAsync {
pub fn new(file: File) -> std::io::Result<Self> {
Ok(Self(FixedVhd::new(file)?))
pub fn new(file: File) -> BlockResult<Self> {
Ok(Self(
FixedVhd::new(file).map_err(|e| BlockError::from(e).with_op(ErrorOp::Open))?,
))
}
}

View File

@@ -569,7 +569,7 @@ pub enum DeviceManagerError {
/// Failed to create FixedVhdDiskAsync
#[error("Failed to create FixedVhdDiskAsync")]
CreateFixedVhdDiskAsync(#[source] io::Error),
CreateFixedVhdDiskAsync(#[source] BlockError),
/// Failed to create FixedVhdDiskSync
#[error("Failed to create FixedVhdDiskSync")]