From 85df0fef0df9430323a3d2d773af9918c07fe3fc Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 20 Mar 2026 18:41:18 +0100 Subject: [PATCH] block: qcow_async: impl AsyncIo scaffold for QcowAsync Add the AsyncIo trait impl with notifier and next_completed_request filled in. The remaining methods are stubbed with unimplemented and will be filled in by subsequent commits. next_completed_request drains io_uring completions first, then falls back to the synthetic completion list. Signed-off-by: Anatol Belski --- block/src/qcow_async.rs | 47 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/block/src/qcow_async.rs b/block/src/qcow_async.rs index b0d93e687..43b1b6aaa 100644 --- a/block/src/qcow_async.rs +++ b/block/src/qcow_async.rs @@ -15,7 +15,7 @@ use std::{fmt, io}; use io_uring::IoUring; use vmm_sys_util::eventfd::EventFd; -use crate::async_io::{BorrowedDiskFd, DiskFileError}; +use crate::async_io::{AsyncIo, AsyncIoResult, BorrowedDiskFd, DiskFileError}; use crate::disk_file; use crate::error::{BlockError, BlockErrorKind, BlockResult, ErrorOp}; use crate::qcow::backing::shared_backing_from; @@ -168,3 +168,48 @@ impl QcowAsync { }) } } + +impl AsyncIo for QcowAsync { + fn notifier(&self) -> &EventFd { + &self.eventfd + } + + fn read_vectored( + &mut self, + offset: libc::off_t, + iovecs: &[libc::iovec], + user_data: u64, + ) -> AsyncIoResult<()> { + unimplemented!() + } + + fn write_vectored( + &mut self, + offset: libc::off_t, + iovecs: &[libc::iovec], + user_data: u64, + ) -> AsyncIoResult<()> { + unimplemented!() + } + + fn fsync(&mut self, user_data: Option) -> AsyncIoResult<()> { + unimplemented!() + } + + fn next_completed_request(&mut self) -> Option<(u64, i32)> { + // Drain io_uring completions first, then synthetic ones. + self.io_uring + .completion() + .next() + .map(|entry| (entry.user_data(), entry.result())) + .or_else(|| self.completion_list.pop_front()) + } + + fn punch_hole(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> { + unimplemented!() + } + + fn write_zeroes(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> { + unimplemented!() + } +}