google/dev-testing-hypervisor
Testing the Capsem hypervisor layer -- Apple VZ (macOS) and KVM (Linux) backends. Use when writing or running tests for VM configuration, VirtioFS FUSE operations, vsock, serial console, virtio devices, or the hypervisor abstraction traits. Covers unit tests, integration tests, KVM CI, and what each backend needs.
npx skills add https://github.com/google/capsem --skill dev-testing-hypervisor
The hypervisor module (crates/capsem-core/src/hypervisor/) has:
Hypervisor, VmHandle, SerialConsole in mod.rsapple_vz/ -- macOS only, uses Virtualization.frameworkkvm/ -- Linux only, uses rust-vmm cratesTests must cover both backends where possible. macOS CI tests Apple VZ, Linux CI (ubuntu-24.04-arm with /dev/kvm) tests KVM.
VirtioFS FUSE operations have 30+ unit tests in kvm/virtio_fs/mod.rs:
Run them:
cargo test -p capsem-core virtio_fs # VirtioFS tests only
cargo test -p capsem-core hypervisor # All hypervisor tests
On macOS these run the KVM module's pure-logic tests (FUSE parsing, FDT generation) but skip anything that needs /dev/kvm. On Linux CI, all tests run including KVM integration.
Cross-crate VM lifecycle tests in crates/capsem-core/tests/:
cargo test -p capsem-core --test '*' # All integration tests
These test the full boot path: config validation, device setup, serial output, vsock handshake. They require VM assets to be built.
ubuntu-24.04-arm with KVM enabledThe x86_64 KVM backend boots bzImage kernels in 64-bit long mode. Key invariants:
KERNEL_LOAD_ADDR + 0x200 (startup_64), not KERNEL_LOAD_ADDR (startup_32). Setting the wrong entry point causes a silent hang -- the vCPU executes 32-bit code in 64-bit mode.#[cfg(target_arch = "x86_64")] hides x86 bugs on macOS. All KVM x86_64 code is behind cfg gates, so it never compiles on macOS (aarch64). Bugs in the x86_64 code path are invisible during macOS development. Always check that the x86_64 CI job passes.VmConfigBuilder::build() reads kernel magic bytes and rejects wrong-arch kernels (bzImage on aarch64, ARM64 Image on x86_64) with ConfigError::ArchMismatch instead of silently hanging.| Change | Tests to run |
|--------|-------------|
| VirtioFS FUSE ops | cargo test virtio_fs + just exec "capsem-doctor -k virtiofs" |
| VM config / boot | cargo test -p capsem-core + just exec (verify boot succeeds) |
| Vsock / serial | cargo test -p capsem-core + just exec "echo ok" (verify I/O works) |
| KVM device model | cargo test -p capsem-core (Linux CI validates) |
| KVM x86_64 boot | cargo test -p capsem-core boot_x86_64 (struct tests run on macOS; full boot needs x86_64 Linux CI) |
| Hypervisor traits | cargo test -p capsem-core on both macOS and Linux CI |
Read references/rust-async-patterns.md for tokio patterns (tasks, channels, streams, error handling). Relevant for vsock, MITM proxy, and VirtioFS async worker code.
.. componentsTake google/dev-testing-hypervisor from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.