mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow: Add physical size test
Verify that a freshly created sparse QCOW2 image reports a physical size smaller than its logical size. Assisted-by: Claude:Opus-4.6 Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
5958872943
commit
abef0e5b69
@@ -193,7 +193,7 @@ mod unit_tests {
|
||||
|
||||
use super::*;
|
||||
use crate::async_io::AsyncIo;
|
||||
use crate::disk_file::{AsyncDiskFile, DiskSize};
|
||||
use crate::disk_file::{AsyncDiskFile, DiskSize, PhysicalSize};
|
||||
use crate::qcow::{QcowFile, RawFile};
|
||||
|
||||
const TEST_SIZE: u64 = 0x5566_7788;
|
||||
@@ -254,4 +254,13 @@ mod unit_tests {
|
||||
let cloned = disk.try_clone().unwrap();
|
||||
assert_async_io_from_dyn(cloned.as_ref(), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn physical_size_less_than_logical() {
|
||||
// make_qcow_file() writes no guest data, so the file on disk
|
||||
// only contains QCOW2 headers and metadata tables.
|
||||
let file = make_qcow_file();
|
||||
let disk = QcowDisk::new(file, false, false, true, false).unwrap();
|
||||
assert!(disk.physical_size().unwrap() < disk.logical_size().unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user