mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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>