block: vhd: impl AsyncDiskFile for FixedVhdDiskAsync

Delegate try_clone() to FixedVhd::clone() and new_async_io() to
FixedVhdAsync, preserving DiskFileError::NewAsyncIo.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-24 17:11:02 +01:00
committed by Bo Chen
parent be6ce5b878
commit c0db1f61ac

View File

@@ -90,6 +90,26 @@ impl disk_file::Resizable for FixedVhdDiskAsync {
impl disk_file::DiskFile for FixedVhdDiskAsync {}
impl disk_file::AsyncDiskFile for FixedVhdDiskAsync {
fn try_clone(&self) -> BlockResult<Box<dyn disk_file::AsyncDiskFile>> {
Ok(Box::new(FixedVhdDiskAsync(self.0.clone())))
}
fn new_async_io(&self, ring_depth: u32) -> BlockResult<Box<dyn AsyncIo>> {
Ok(Box::new(
FixedVhdAsync::new(
self.0.as_raw_fd(),
ring_depth,
self.0.logical_size().unwrap(),
)
.map_err(|e| {
BlockError::new(BlockErrorKind::Io, DiskFileError::NewAsyncIo(e))
.with_op(ErrorOp::Open)
})?,
))
}
}
pub struct FixedVhdAsync {
raw_file_async: RawFileAsync,
size: u64,