block: vhdx: impl AsyncDiskFile for VhdxDiskSync

try_clone() shares the Arc<Mutex<Vhdx>>. new_async_io() creates
VhdxSync with a cloned Arc (no error path, infallible).

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-25 16:43:37 +01:00
committed by Bo Chen
parent e99ad15939
commit cf9496376f

View File

@@ -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<Box<dyn disk_file::AsyncDiskFile>> {
Ok(Box::new(VhdxDiskSync {
vhdx_file: Arc::clone(&self.vhdx_file),
}))
}
fn new_async_io(&self, _ring_depth: u32) -> BlockResult<Box<dyn AsyncIo>> {
Ok(Box::new(VhdxSync::new(Arc::clone(&self.vhdx_file))))
}
}
impl DiskFile for VhdxDiskSync {
fn logical_size(&mut self) -> DiskFileResult<u64> {
Ok(self.vhdx_file.lock().unwrap().virtual_disk_size())