From cf9496376f84b9bb42c2afa16929d43af87d60a5 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 25 Mar 2026 16:43:37 +0100 Subject: [PATCH] block: vhdx: impl AsyncDiskFile for VhdxDiskSync try_clone() shares the Arc>. new_async_io() creates VhdxSync with a cloned Arc (no error path, infallible). Signed-off-by: Anatol Belski --- block/src/vhdx_sync.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/src/vhdx_sync.rs b/block/src/vhdx_sync.rs index 48d25714e..867997825 100644 --- a/block/src/vhdx_sync.rs +++ b/block/src/vhdx_sync.rs @@ -82,6 +82,18 @@ impl disk_file::Resizable for VhdxDiskSync { impl disk_file::DiskFile for VhdxDiskSync {} +impl disk_file::AsyncDiskFile for VhdxDiskSync { + fn try_clone(&self) -> BlockResult> { + Ok(Box::new(VhdxDiskSync { + vhdx_file: Arc::clone(&self.vhdx_file), + })) + } + + fn new_async_io(&self, _ring_depth: u32) -> BlockResult> { + Ok(Box::new(VhdxSync::new(Arc::clone(&self.vhdx_file)))) + } +} + impl DiskFile for VhdxDiskSync { fn logical_size(&mut self) -> DiskFileResult { Ok(self.vhdx_file.lock().unwrap().virtual_disk_size())