block: Make detect_image_type return BlockResult with context

Convert detect_image_type() from io::Result to BlockResult so
that I/O failures carry the operation name in the error context.
Update the corresponding vmm error variant to wrap BlockError.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-05 16:03:19 +01:00
committed by Rob Bradford
parent 58bdfaee3a
commit b1bc376c91
2 changed files with 9 additions and 5 deletions

View File

@@ -41,7 +41,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,
preallocate_disk, qcow, vhdx,
preallocate_disk, vhdx,
};
#[cfg(feature = "io_uring")]
use block::{fixed_vhd_async::FixedVhdDiskAsync, raw_async::RawFileDisk};
@@ -266,7 +266,7 @@ pub enum DeviceManagerError {
/// Failed to parse disk image format
#[error("Failed to parse disk image format")]
DetectImageType(#[source] io::Error),
DetectImageType(#[source] BlockError),
/// Cannot create serial manager
#[error("Cannot create serial manager")]