block: qcow: QcowDiskSync returns BlockResult with path context

Change QcowDiskSync::new() to return BlockResult instead of
qcow::Result, mapping format specific errors to the appropriate
BlockErrorKind at the crate boundary. The vmm caller attaches
the disk image path to the error so failures identify which
file was being opened.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-05 15:21:06 +01:00
committed by Rob Bradford
parent 8c2794533d
commit 58bdfaee3a
2 changed files with 41 additions and 24 deletions

View File

@@ -33,6 +33,7 @@ use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START};
use arch::{DeviceType, MmioDeviceInfo};
use arch::{NumaNodes, layout};
use block::async_io::DiskFile;
use block::error::BlockError;
use block::fixed_vhd_sync::FixedVhdDiskSync;
use block::qcow_sync::QcowDiskSync;
use block::raw_async_aio::RawFileDiskAio;
@@ -575,7 +576,7 @@ pub enum DeviceManagerError {
/// Failed to create QcowDiskSync
#[error("Failed to create QcowDiskSync")]
CreateQcowDiskSync(#[source] qcow::Error),
CreateQcowDiskSync(#[source] BlockError),
/// Failed to create FixedVhdxDiskSync
#[error("Failed to create FixedVhdxDiskSync")]
@@ -2776,6 +2777,10 @@ impl DeviceManager {
disk_cfg.backing_files,
disk_cfg.sparse,
)
.map_err(|e| match &disk_cfg.path {
Some(p) => e.with_path(p),
None => e,
})
.map_err(DeviceManagerError::CreateQcowDiskSync)?,
) as Box<dyn DiskFile>
}