← 输入框|github.com|刷新
Skip to content

tests: Share qemu-img execution across test suites - #9267

Open
weltling wants to merge 5 commits into
cloud-hypervisor:mainfrom
weltling:block-qemu-img-test-helper
Open

weltling wants to merge 5 commits into
cloud-hypervisor:mainfrom
weltling:block-qemu-img-test-helper

Conversation

@weltling

@weltling weltling commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Combine qemu-img usages in a shared QemuImg helper across the test suites. Every qemu-img command must succeed. A missing executable or nonzero exit status fails the test. Failures report the command and error details.

This is prerequisite work for #8707.

@weltling
weltling requested a review from a team as a code owner November 2, 2026 20:15
@weltling
weltling force-pushed the block-qemu-img-test-helper branch 2 times, most recently from 14b4fd7 to 5fb8cee Compare November 2, 2026 21:48

@sboeuf sboeuf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay, but TBH I'm not sure this PR buys us anything. It's barely more readable than the previous versions, and you're loosing the context where it failed through various error messages that you've removed.

Comment on lines +41 to +45
#[cfg(test)]
pub(crate) fn current_dir(&mut self, directory: impl AsRef<Path>) -> &mut Self {
self.command.current_dir(directory);
self
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not have a dedicated function just for tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote this by using the explicit image paths, so this function has gone.

Thanks

Comment on lines +80 to +81
#[cfg(test)]
mod tests {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's really valuable to have unit tests for this small encapsulation of qemu-img which is useful only through test. I mean testing tests tests 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, dropped those :)

Add a shared QemuImg builder under the integration test directory.
Include it from block unit tests without adding a crate or dependency.

Require the executable and a successful exit for every subcommand.
Accept caller context and report the command and stderr on failures.

Use the helper for VHDX fixtures and remove skipped fixture tests.
Document the executable requirement for local test runs.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Route all integration image commands through QemuImg. Require a
successful exit for setup, info and map commands. Preserve caller
operation context alongside command arguments and stderr on failure.

Replace shell command strings with argument lists so file paths are
passed intact. Share failure reports across disk test helpers.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Use QemuImg to create the Windows QCOW2 overlay. Keep image creation
mandatory and preserve its operation context with command details
and stderr on failure.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Use QemuImg for QCOW2 chain and VHDX fixture generation. Pass full
source and output paths while keeping relative QCOW2 backing names
in image metadata. Add operation context to fixture failure reports.

Require the executable and successful command exit statuses. Fail on
fixture file errors instead of returning from tests without running
their checks.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
Use QemuImg for disk image setup and compressed image fixtures.
Preserve image formats, backing paths, preallocation modes and sizes.

Require command success and include operation context, command details
and stderr on failure before a benchmark starts.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
@weltling
weltling force-pushed the block-qemu-img-test-helper branch from 5fb8cee to ca4aec5 Compare November 3, 2026 11:41
@weltling

weltling commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Looks okay, but TBH I'm not sure this PR buys us anything. It's barely more readable than the previous versions, and you're loosing the context where it failed through various error messages that you've removed.

Thanks for the review. The purpose is to unify the different qemu-img invocation patterns as we start moving image checks from integration tests into block unit tests. It is already a test suite dependency. Having consistent execution and failure handling should make that migration easier and recognize qemu-img as a dependency.

I have simplified the wrapper and restored caller specific error context through run(context). Failures keep the operation message and add the command and error details.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants