mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow: Test async alignment() with O_DIRECT
Verify that QcowAsync reports at least SECTOR_SIZE alignment when O_DIRECT is active. Skipped on filesystems that do not support O_DIRECT (e.g. tmpfs). Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
854b686293
commit
dd79b1899d
@@ -1009,4 +1009,27 @@ mod unit_tests {
|
||||
let async_io = disk.new_async_io(1).unwrap();
|
||||
assert_eq!(async_io.alignment(), SECTOR_SIZE);
|
||||
}
|
||||
|
||||
/// Returns None if O_DIRECT is not supported (e.g. tmpfs).
|
||||
fn try_create_direct_io_disk(temp_file: &TempFile, file_size: u64) -> Option<QcowDiskAsync> {
|
||||
{
|
||||
let raw_file = RawFile::new(temp_file.as_file().try_clone().unwrap(), false);
|
||||
QcowFile::new(raw_file, 3, file_size, true).unwrap();
|
||||
}
|
||||
QcowDiskAsync::new(temp_file.as_file().try_clone().unwrap(), true, false, true).ok()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_qcow_async_alignment_with_direct_io() {
|
||||
let temp_file = TempFile::new().unwrap();
|
||||
let disk = match try_create_direct_io_disk(&temp_file, 100 * 1024 * 1024) {
|
||||
Some(d) => d,
|
||||
None => {
|
||||
eprintln!("skipping: O_DIRECT not supported on this filesystem");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let async_io = disk.new_async_io(1).unwrap();
|
||||
assert!(async_io.alignment() >= SECTOR_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user