mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Add AlignedBuffer
The block code repeatedly open-codes O_DIRECT alignment calculations and bounce-buffer allocation at each I/O site. Add an AlignedBuffer struct that handles the alignment and allocation in one place, using FileExt (read_exact_at and write_all_at) for the I/O (so no need for custom libc wrappers). The caller creates an AlignedBuffer with an offset, length and alignment, then uses read_from and write_to for aligned I/O and as_slice and as_mut_slice to access the logical data portion within the aligned region. This is a lot like the AlignedBuf that was already existing in the QCOW2 code but is a more generalised version. Assisted-by: Claude:Opus-4.6 Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -14,6 +14,7 @@ pub mod factory;
|
||||
#[path = "io/mod.rs"]
|
||||
mod io_impl;
|
||||
pub use io_impl::{async_io, fcntl, request};
|
||||
pub(crate) mod aligned_buffer;
|
||||
pub mod formats;
|
||||
mod sparse;
|
||||
use std::alloc::{Layout, alloc_zeroed};
|
||||
|
||||
Reference in New Issue
Block a user