From d75bd1675c463103701d1f057e885c6724bca91a Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 15 Dec 2025 20:14:50 +0100 Subject: [PATCH] performance-metrics: Add QCOW2 backing file performance test Add sequential and random read performance tests for QCOW2 overlays with QCOW2 backing files. Signed-off-by: Anatol Belski --- performance-metrics/src/main.rs | 32 +++++++++++++++++++- performance-metrics/src/performance_tests.rs | 16 ++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/performance-metrics/src/main.rs b/performance-metrics/src/main.rs index 79c0699cf..e25a84d34 100644 --- a/performance-metrics/src/main.rs +++ b/performance-metrics/src/main.rs @@ -319,7 +319,7 @@ mod adjuster { } } -const TEST_LIST: [PerformanceTest; 30] = [ +const TEST_LIST: [PerformanceTest; 32] = [ PerformanceTest { name: "boot_time_ms", func_ptr: performance_boot_time, @@ -710,6 +710,36 @@ const TEST_LIST: [PerformanceTest; 30] = [ }, unit_adjuster: adjuster::identity, }, + PerformanceTest { + name: "block_qcow2_backing_qcow2_read_MiBps", + func_ptr: performance_block_io, + control: PerformanceTestControl { + num_queues: Some(1), + queue_size: Some(128), + block_control: Some(BlockControl { + fio_ops: FioOps::Read, + bandwidth: true, + test_file: OVERLAY_WITH_QCOW2_BACKING, + }), + ..PerformanceTestControl::default() + }, + unit_adjuster: adjuster::Bps_to_MiBps, + }, + PerformanceTest { + name: "block_qcow2_backing_qcow2_random_read_MiBps", + func_ptr: performance_block_io, + control: PerformanceTestControl { + num_queues: Some(1), + queue_size: Some(128), + block_control: Some(BlockControl { + fio_ops: FioOps::RandomRead, + bandwidth: true, + test_file: OVERLAY_WITH_QCOW2_BACKING, + }), + ..PerformanceTestControl::default() + }, + unit_adjuster: adjuster::Bps_to_MiBps, + }, ]; fn run_test_with_timeout( diff --git a/performance-metrics/src/performance_tests.rs b/performance-metrics/src/performance_tests.rs index 049310a09..140703701 100644 --- a/performance-metrics/src/performance_tests.rs +++ b/performance-metrics/src/performance_tests.rs @@ -33,6 +33,8 @@ enum Error { // The test image cannot be created on tmpfs (e.g. /tmp) filesystem, // as tmpfs does not support O_DIRECT pub const BLK_IO_TEST_IMG: &str = "/var/tmp/ch-blk-io-test.img"; +const QCOW2_BACKING_FILE: &str = "/var/tmp/ch-blk-io-test-qcow2-backing.qcow2"; +pub const OVERLAY_WITH_QCOW2_BACKING: &str = "/var/tmp/ch-blk-io-test-overlay-qcow2.qcow2"; pub fn init_tests(overrides: &PerformanceTestOverrides) { let mut cmd = format!("dd if=/dev/zero of={BLK_IO_TEST_IMG} bs=1M count=4096"); @@ -54,11 +56,25 @@ pub fn init_tests(overrides: &PerformanceTestOverrides) { } assert!(exec_host_command_output(&cmd).status.success()); + + // QCOW2 backing file for backing file tests + cmd = format!("qemu-img create -f qcow2 -o preallocation=full {QCOW2_BACKING_FILE} 4G"); + assert!(exec_host_command_output(&cmd).status.success()); + + // QCOW2 overlay with QCOW2 backing + cmd = format!( + "qemu-img create -f qcow2 -b {QCOW2_BACKING_FILE} -F qcow2 {OVERLAY_WITH_QCOW2_BACKING} 4G" + ); + assert!(exec_host_command_output(&cmd).status.success()); } pub fn cleanup_tests() { fs::remove_file(BLK_IO_TEST_IMG) .unwrap_or_else(|_| panic!("Failed to remove file '{BLK_IO_TEST_IMG}'.")); + fs::remove_file(QCOW2_BACKING_FILE) + .unwrap_or_else(|_| panic!("Failed to remove file '{QCOW2_BACKING_FILE}'.")); + fs::remove_file(OVERLAY_WITH_QCOW2_BACKING) + .unwrap_or_else(|_| panic!("Failed to remove file '{OVERLAY_WITH_QCOW2_BACKING}'.")); } // Performance tests are expected to be executed sequentially, so we can