From 15073edf081c03949344526ba1a15a8f7c6f16c9 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 24 Mar 2026 17:01:55 +0100 Subject: [PATCH] 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 --- block/src/fixed_vhd_async.rs | 7 +++++-- vmm/src/device_manager.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block/src/fixed_vhd_async.rs b/block/src/fixed_vhd_async.rs index 6e858f74a..141435420 100644 --- a/block/src/fixed_vhd_async.rs +++ b/block/src/fixed_vhd_async.rs @@ -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 { - Ok(Self(FixedVhd::new(file)?)) + pub fn new(file: File) -> BlockResult { + Ok(Self( + FixedVhd::new(file).map_err(|e| BlockError::from(e).with_op(ErrorOp::Open))?, + )) } } diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 342f99b37..26bc24dbc 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -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")]