VMM 测试运行与调试
vmm-tests
使用 cargo xflowey vmm-tests-run 在本地运行 VMM 测试。在运行或调试 VMM 测试,或需要理解 petri 测试框架、工件处理(artifact handling)或 VMM 测试交叉编译时使用。
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 2.0k
- Forks
- 277
01 前言 Front Matter
- name
- vmm-tests
- description
- Run VMM tests locally with cargo xflowey vmm-tests-run. Load when running or debugging VMM tests, or when you need to understand the petri test framework, artifact handling, or cross-compilation for VMM tests.
03 SKILL.md 正文
Running VMM Tests
VMM tests boot full virtual machines and validate behavior. They live in
vmm_tests/vmm_tests/tests/tests/ and use the petri test framework.
Always use cargo xflowey vmm-tests-run — never raw cargo nextest run -p vmm_tests. The xflowey command handles artifact discovery, dependency
building, and test execution automatically.
Quick Start
# Run a specific test
cargo xflowey vmm-tests-run --filter "test(my_test_name)"
# Run all tests matching a prefix
cargo xflowey vmm-tests-run --filter "test(/^boot_/)"
# Run all tests (rarely needed locally)
cargo xflowey vmm-tests-run --filter "all()"
Omitting --filter selects all tests. Use an explicit selection so the
command's scope is clear.
Output Directory
Usually you don't need --dir — it defaults to target/vmm_tests. When
cross-compiling for Windows from WSL2, --dir on the Windows filesystem (e.g.,
--dir /mnt/d/vmm_tests) is required only when the selected tests use disk
images that need a Windows filesystem: Hyper-V tests, or tests using VHDX
/ dynamic VHD1 images. For everything else (streamed disks, or plain fixed
VHD1 / VMGS / ISO files), the default WSL-side directory works. vmm-tests-run
detects this and errors with a clear message if --dir is required.
Filter Syntax
Filters use nextest filter expressions:
| Expression | Matches |
|---|---|
test(foo) |
Tests with foo in the name |
test(/^boot_/) |
Tests starting with boot_ (regex) |
test(foo) & !test(hyperv) |
foo tests excluding Hyper-V variants |
all() |
Everything |
Platform Targeting
By default, tests build for the current host. Use --target for
cross-compilation:
# Cross-compile and run Windows tests from WSL2
cargo xflowey vmm-tests-run --target windows-x64 --filter "test(my_test_name)"
| Target | Description |
|---|---|
windows-x64 |
Windows x86_64 (Hyper-V / WHP) |
windows-aarch64 |
Windows ARM64 (Hyper-V / WHP) |
linux-x64 |
Linux x86_64 |
Windows from WSL2: Cross-compilation setup is required first — see
Guide/src/dev_guide/getting_started/cross_compile.md.
Artifact Handling (Lazy Fetch)
By default, disk images (VHDs/ISOs) are streamed on demand via HTTP with local SQLite caching. This avoids multi-GB upfront downloads.
--no-lazy-fetch— download all images upfront instead of streaming- Lazy fetch is automatically disabled for Hyper-V tests (they need local files)
--skip-vhd-prompt— skip interactive VHD download prompts (useful for automation)
Viewing Logs
Test output (petri logs, guest serial, etc.) is shown by default on failure.
For full OpenVMM tracing, set the OPENVMM_LOG environment variable:
OPENVMM_LOG=trace cargo xflowey vmm-tests-run --filter "test(foo)"
Other Useful Flags
| Flag | Purpose |
|---|---|
--release |
Release build (default: debug) |
--build-only |
Build without running |
--verbose |
Verbose cargo output |
--install-missing-deps |
Auto-install missing system dependencies |
--custom-uefi-firmware <PATH> |
Use a custom UEFI firmware (MSVM.fd) |
--custom-kernel <PATH> |
Use a custom kernel image |
Run cargo xflowey vmm-tests-run --help for the full option list.
Common Pitfalls
- Don't use
cargo nextest run -p vmm_testsdirectly — artifacts won't be present and tests will fail with missing-artifact errors. - Hyper-V tests — require Hyper-V Administrators group membership and disable lazy fetch automatically.
- CI failures — use the
openvmm-ci-investigationskill to diagnose failing VMM tests in CI, not this workflow.
04 同仓库更多 Skills
OpenVMM UEFI 固件更新
update-mu-msvm
将 OpenVMM UEFI 固件更新至最新发布的 microsoft/mu_msvm 版本。适用于更新 mu_msvm、升级 UEFI 依赖、刷新固件 Nix 哈希,或准备固件集成拉取请求(pull request)。
OpenVMM CI 失败调查
openvmm-ci-investigation
调查 OpenVMM PR 上的 CI 失败。当某个 PR 存在失败的 CI 检查、需要下载和分析测试产物,或需要诊断构建、fmt、clippy 或 VMM 测试失败时加载。
OpenVMM 指南维护
guide-maintenance
维护 OpenVMM 指南。在以下情况加载:(1) 添加、删除或移动指南页面;(2) 添加新设备 crate,或添加/更改需要文档覆盖的 CLI 接口;(3) 根据代码变更审计指南的时效性。
OpenVMM 模糊测试调试
fuzzing
运行、优化和调试 OpenVMM 模糊测试器(fuzzer)。涵盖 cargo-fuzz 目标、崩溃复现、lldb 调试、代码覆盖率分析、熵优化以及多目标并行测试活动。