mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: block: Add support for alignment restrictions
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>
This commit is contained in:
committed by
Rob Bradford
parent
e483cde1bb
commit
c5a656c9dc
@@ -87,7 +87,9 @@ impl VhostUserBlkBackend {
|
||||
let image_id = build_disk_image_id(&PathBuf::from(&image_path));
|
||||
let image_type = qcow::detect_image_type(&raw_img).unwrap();
|
||||
let mut image = match image_type {
|
||||
ImageType::Raw => Box::new(vm_virtio::RawFile::new(raw_img)) as Box<dyn DiskFile>,
|
||||
ImageType::Raw => {
|
||||
Box::new(vm_virtio::RawFile::new(raw_img, false)) as Box<dyn DiskFile>
|
||||
}
|
||||
ImageType::Qcow2 => Box::new(QcowFile::from(raw_img).unwrap()) as Box<dyn DiskFile>,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user