microsoft/openvmm

Public

mirrored fromhttps://github.com/microsoft/openvmmAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1b63f0f0704167a997414d57ddd465f9d2061819

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/copilot-instructions.md

116lines · modecode

1# OpenVMM Repository
2
3## Project Overview
4OpenVMM is a modular, cross-platform Virtual Machine Monitor (VMM) written in Rust. This repository is home to both OpenVMM and OpenHCL (a paravisor). The project focuses on creating secure, high-performance virtualization infrastructure.
5
6## Technology Stack
7- **Language**: Rust (using Cargo build system)
8- **Build Tool**: Cargo with custom xtask automation
9- **Package Management**: Cargo + custom flowey pipeline tools
10- **Testing Framework**: Rust unit tests + cargo-nextest (recommended)
11- **Documentation**: mdBook (in `Guide/` folder)
12
13## Project Structure
14- `openvmm/` - Core OpenVMM VMM implementation
15- `openhcl/` - OpenHCL paravisor implementation
16- `vmm_tests/` - Integration tests using the petri framework
17- `support/` - Shared support libraries and utilities
18- `vm/` - VM components (devices, chipset, etc.)
19- `Guide/` - Documentation source (published at https://openvmm.dev)
20- `xtask/` - Custom build and automation tasks
21- `flowey/` - Pipeline and build automation framework
22
23## Build Commands
24
25### Initial Setup
26Before building for the first time, restore required dependencies:
27```bash
28cargo xflowey restore-packages
29```
30
31### Building
32Build the project using standard Cargo:
33```bash
34cargo build
35```
36
37For release builds:
38```bash
39cargo build --release
40```
41
42### Cross-compilation
43The project supports cross-compilation for `x86_64` and `aarch64` architectures. Note:
44- Some components (like OpenHCL) can only be built from Linux (WSL2 counts as Linux)
45- For cross-compilation from WSL2 to Windows, see `Guide/src/dev_guide/getting_started/cross_compile.md` and source `. ./build_support/setup_windows_cross.sh`
46
47## Testing
48
49### Unit Tests
50Use cargo-nextest (recommended) or cargo test:
51```bash
52# Recommended - install with: cargo install cargo-nextest --locked
53# Run tests in specific packages you are modifying (default won't run anything)
54cargo nextest run -p <package-name>
55
56# Or use standard cargo test
57cargo test -p <package-name>
58```
59
60Configure test runs using `.config/nextest.toml` for resource management and timeouts.
61
62### Test Types
63- **Unit tests**: Spread throughout crates, marked by `#[cfg(test)]` blocks
64- **VMM tests**: Integration tests in `vmm_tests/` using the petri framework for Hyper-V and OpenVMM VMs (requires additional setup)
65- **Fuzz tests**: Nondeterministic tests ensuring no panics across trust boundaries
66
67## Linting and Formatting
68
69### Required Before Each Commit
70Always run formatting and documentation checks before committing:
71```bash
72cargo xtask fmt --fix
73cargo doc
74```
75
76This ensures:
77- All source code follows rustfmt standards
78- Generated pipeline files maintain consistent style
79- Code follows project-specific "house rules" (copyright headers, naming conventions, etc.)
80- No errors in rustdoc comments
81
82### Available Checks
83Run specific formatting passes:
84```bash
85cargo xtask fmt --help # See all available passes
86cargo xtask fmt --pass rustfmt
87cargo xtask fmt --pass house-rules
88```
89
90## Code Standards
91
92### Key Guidelines
931. Follow Rust best practices and idiomatic patterns
942. Maintain existing code structure and organization
953. Write unit tests for new functionality
964. Document public APIs and complex logic
975. Update documentation in `Guide/` folder when adding features or changing behavior
98
99### Domain-specific Guidelines
100Both OpenVMM and OpenHCL process data from untrusted sources. OpenHCL runs in a constrained environment.
101
102**Trust Boundaries** (critical for security):
103- **OpenVMM does not trust the VTL0 guest** - code must not panic on any guest input
104- **OpenHCL does not trust the root** - code must not panic on any root input
105- **OpenHCL does not trust the VTL0 guest** - less critical than OpenVMM, but the attack surface is subtle and needs human review
106
107When possible:
1081. Avoid `unsafe` code
1092. Avoid taking new external dependencies, especially those that significantly increase binary size
1103. Ensure code doesn't panic across trust boundaries
111
112## Testing Best Practices
113- Thoroughly test code with unit tests whenever possible
114- Add VMM test cases for interesting integration points
115- Unit tests should be fast, isolated, and not require root/administrator access
116- Mark tests requiring special setup with `#[ignore]` for manual testing
117