From 4bf3672fad35a80e7ccadffaad35a5d1044ae17d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 27 Mar 2026 13:00:20 +0100 Subject: [PATCH] performance-metrics: Add compressed async QCOW2 tempfile helper Add compressed_qcow_async_tempfile which creates a zlib compressed QCOW2 image via qemu-img and opens it via QcowDiskAsync. Mirrors the existing compressed_qcow_tempfile for io_uring benchmarks. Signed-off-by: Anatol Belski --- performance-metrics/src/util.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/performance-metrics/src/util.rs b/performance-metrics/src/util.rs index c96d07253..6482bd115 100644 --- a/performance-metrics/src/util.rs +++ b/performance-metrics/src/util.rs @@ -257,6 +257,20 @@ pub fn compressed_qcow_tempfile(num_clusters: usize) -> (TempFile, QcowDiskSync) (tmp, disk) } +/// Compressed QCOW2 opened via QcowDiskAsync. +pub fn compressed_qcow_async_tempfile(num_clusters: usize) -> (TempFile, QcowDiskAsync) { + let tmp = create_compressed_qcow_tempfile(num_clusters); + let path = tmp.as_path().to_str().unwrap().to_string(); + let disk = QcowDiskAsync::new( + File::open(&path).expect("failed to open compressed qcow2"), + false, + false, + true, + ) + .expect("failed to open compressed qcow2 via QcowDiskAsync"); + (tmp, disk) +} + /// Number of data clusters covered by a single L2 table (64 KiB cluster, /// 8-byte entries -> 8192 entries per L2 table). pub const L2_ENTRIES_PER_TABLE: usize = QCOW_CLUSTER_SIZE as usize / 8;