mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-24 21:45:28 +00:00
c5a656c9dc
Doing I/O on an image opened with O_DIRECT requires to adhere to certain restrictions, requiring the following elements to be aligned: - Address of the source/destination memory buffer. - File offset. - Length of the data to be read/written. The actual alignment value depends on various elements, and according to open(2) "(...) there is currently no filesystem-independent interface for an application to discover these restrictions (...)". To discover such value, we iterate through a list of alignments (currently, 512 and 4096) calling pread() with each one and checking if the operation succeeded. We also extend RawFile so it can be used as a backend for QcowFile, so the later can be easily adapted to support O_DIRECT too. Signed-off-by: Sergio Lopez <slp@redhat.com>