Skip to content

Commit 3fb1f62

Browse files
authored
guide: comprehensive overhaul of the OpenVMM Guide (#28)
This PR comprehensively overhauls the OpenVMM Guide, rewriting it from the ground-up to better reflect the current state of the project, and to make it more accessible to new users and potential contributors. I _strongly_ recommend reviewing this PR by checking out my branch locally, and running `mdbook serve Guide` locally. It will be very hard to judge some of the organizational choices and stylistic changes I've made by looking at raw, un-rendered Markdown. **At a macro level:** The Guide no longer assumes that all users are also developers. Docs that explain how to run / interact with OpenVMM/OpenHCL are now distinct from docs explaining how to build / contribute to the project. **At a micro level:** I've rewritten and shuffled around the content on just about every existing Guide page, ensuring that information is up-to-date, and presented in a logical order. Some notable things _not_ included in this PR: - Rewrites of the Introduction sections (that we absolutely must update prior to open-source) - Getting these right will require a bit more time, and will land in a separate PR this week. - Fleshing out the content under the "Developer Reference" section of the guide - Notably: adding some brief enumerations / stub articles discussing the various Devices / Virtualization Backends we support - Publishing OpenVMM's `rustdocs`s to GitHub Pages - I've included a TODO link in SUMMARY.md right at the end ("OpenVMM Crate Docs") - This should be relatively straightforward, requiring a bit of flowey plumbing in the existing "publish guide" job in CI. This should happen in its own standalone PR.
1 parent 842efd8 commit 3fb1f62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1309
-1735
lines changed

Guide/book.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
language = "en"
55
multilingual = false
66
src = "src"
7-
title = "OpenVMM Developer Guide"
7+
title = "The OpenVMM Guide"
88

99
[build]
1010
create-missing = false
11+
12+
[output.html]
13+
git-repository-url = "https://github.com/microsoft/OpenVMM"
14+
git-repository-icon = "fa-github"
15+
edit-url-template = "https://github.com/microsoft/OpenVMM/edit/main/Guide/{path}"

Guide/docfx.json

-36
This file was deleted.

Guide/index.md

-1
This file was deleted.

Guide/src/SUMMARY.md

+65-42
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,67 @@
11
# Summary
22

3-
- [Introduction](./index.md)
4-
- [Getting started on Windows](./getting_started.md)
5-
- [Getting started on WSL](./getting_started_wsl.md)
6-
- [Development Environment Setup](./ide_setup.md)
7-
- [Developing in OpenVMM](./process/index.md)
8-
- [Coding conventions](./process/conventions.md)
9-
- [Documentation](./process/docs.md)
10-
- [Tests](./process/tests.md)
11-
- [Scripts](./process/scripts.md)
12-
- [Diagnostics](./diag/index.md)
13-
- [Logging](./diag/logging.md)
14-
- [Inspection](./diag/inspect.md)
15-
- [Hardware Debugging (gdbstub)](./diag/gdbstub.md)
16-
- [Kernel Debugging (KDNET)](./diag/kdnet.md)
17-
- [Devices](./devices/index.md)
18-
- [Infrastructure](./devices/infra/index.md)
19-
- [VmBus](./devices/infra/vmbus.md)
20-
- [Virtio](./devices/infra/virtio.md)
21-
- [Block storage](./devices/block.md)
22-
- [VPMEM](./devices/pmem.md)
23-
- [Networking](./devices/net.md)
24-
- [File system](./devices/fs/index.md)
25-
- [Plan 9](./devices/fs/9p.md)
26-
- [Virtio-fs](./devices/fs/virtiofs.md)
27-
- [LxUtil](./devices/fs/lxutil.md)
28-
- [OpenVMM](./openvmm/index.md)
29-
- [Build and Run OpenVMM](./openvmm/build.md)
30-
- [OpenHCL](./openhcl/index.md)
31-
- [Building OpenHCL](./openhcl/build.md)
32-
- [Run OpenHCL using OpenVMM on WHP](./openhcl/run_with_openvmm.md)
33-
- [Run OpenHCL via OpenVMM from within WSL2 with cross compilation](./openhcl/cross_compile.md)
34-
- [Diagnostics](./openhcl/diag.md)
35-
- [PCAP network packet capture](./openhcl/diag/packet_capture.md)
36-
- [CVM restrictions](./openhcl/diag/cvm_restrictions.md)
37-
- [Developer Features](./openhcl/dev_features.md)
38-
- [Kernel development](./openhcl/kernel.md)
39-
- [Performance analysis](./openhcl/perf.md)
40-
- [Troubleshooting](./openhcl/troubleshoot.md)
41-
- [Vmgstool](./vmgstool.md)
42-
- [Fuzzing](./fuzzing/index.md)
43-
- [Running Fuzzers](./fuzzing/running.md)
44-
- [Writing Fuzzers](./fuzzing/writing.md)
3+
[Introduction](./index.md)
4+
5+
# User Guide
6+
7+
- [OpenVMM](./user_guide/openvmm.md)
8+
- [Running OpenVMM](./user_guide/openvmm/run.md)
9+
- [Examples](./user_guide/openvmm/run/examples.md)
10+
- [CLI](./user_guide/openvmm/run/cli.md)
11+
- [Interactive Console](./user_guide/openvmm/run/interactive_console.md)
12+
- [Graphical Console](./user_guide/openvmm/run/graphical_console.md)
13+
- [Logging](./user_guide/openvmm/run/logging.md)
14+
- [Troubleshooting](./user_guide/openvmm/troubleshooting.md)
15+
- [OpenHCL](./user_guide/openhcl.md)
16+
- [Running OpenHCL](./user_guide/openhcl/run.md)
17+
- [On Windows - Hyper-V](./user_guide/openhcl/run/hyperv.md)
18+
- [On Windows - OpenVMM](./user_guide/openhcl/run/openvmm.md)
19+
- [On Linux - OpenVMM]()
20+
- [Troubleshooting](./user_guide/openhcl/troubleshooting.md)
21+
- [Diagnostics](./user_guide/openhcl/diag.md)
22+
- [Preface: CVM restrictions](./user_guide/openhcl/diag/cvm_restrictions.md)
23+
- [ohcldiag-dev](./user_guide/openhcl/diag/ohcldiag_dev.md)
24+
- [Network packet capture (PCAP)](./user_guide/openhcl/diag/ohcldiag_dev/pcap.md)
25+
- [Performance analysis](./user_guide/openhcl/diag/ohcldiag_dev/perf.md)
26+
- [Tracing](./user_guide/openhcl/diag/tracing.md)
27+
28+
# Developer Guide
29+
30+
- [Getting Started](./dev_guide/getting_started.md)
31+
- [On Linux / WSL2](./dev_guide/getting_started/linux.md)
32+
- [On Windows](./dev_guide/getting_started/windows.md)
33+
- [Building OpenVMM](./dev_guide/getting_started/build_openvmm.md)
34+
- [Building OpenHCL](./dev_guide/getting_started/build_openhcl.md)
35+
- [Building a Custom Kernel](./dev_guide/getting_started/build_ohcl_kernel.md)
36+
- [Suggested Dev Environment](./dev_guide/getting_started/suggested_dev_env.md)
37+
- [Testing](./dev_guide/tests.md)
38+
- [Unit Tests](./dev_guide/tests/unit.md)
39+
- [VMM Tests](./dev_guide/tests/vmm.md)
40+
- [Azure-hosted Test Images](./dev_guide/tests/vmm/azure_images.md)
41+
- [Fuzzing](./dev_guide/tests/fuzzing.md)
42+
- [Running Fuzzers](./dev_guide/tests/fuzzing/running.md)
43+
- [Writing Fuzzers](./dev_guide/tests/fuzzing/writing.md)
44+
- [Developer Features](./dev_guide/dev_feats.md)
45+
- [Hardware Debugging (gdbstub)](./dev_guide/dev_feats/gdbstub.md)
46+
- [Kernel Debugging (KDNET)](./dev_guide/dev_feats/kdnet.md)
47+
- [Developer Tools / Utilities](./dev_guide/dev_tools.md)
48+
- [`cargo xtask`](./dev_guide/dev_tools/xtask.md)
49+
- [`cargo xflowey`](./dev_guide/dev_tools/xflowey.md)
50+
- [VmgsTool](./dev_guide/dev_tools/vmgstool.md)
51+
- [update-rootfs.py]()
52+
- [igvmfilegen]()
53+
- [guest_test_uefi](./dev_guide/dev_tools/guest_test_uefi.md)
54+
- [Contributing](./dev_guide/contrib.md)
55+
- [Coding Conventions](./dev_guide/contrib/code.md)
56+
- [Submitting Changes](./dev_guide/contrib/pr.md)
57+
- [Guide Updates](./dev_guide/contrib/guide.md)
58+
59+
# Developer Reference
60+
61+
- [OpenVMM Architecture]()
62+
- [OpenHCL Architecture]()
63+
- [Devices]()
64+
65+
---
66+
67+
[OpenVMM Crate Docs]()

Guide/src/dev_guide/contrib.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Contributing

Guide/src/process/conventions.md Guide/src/dev_guide/contrib/code.md

+61-53
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Coding conventions
22

3-
## Formatting
3+
One of our major goals with OpenVMM is to provide a high quality coding
4+
experience for contributors, starting first-and-foremost by having a consistent
5+
set of coding conventions in the project.
46

5-
**TL;DR:** Run [`cargo xtask fmt`](./scripts.md#cargo-xtask) to catch (and fix)
6-
formatting issues.
7+
[Do your part](https://youtu.be/-_7FaWnlhS4?t=10) and keep OpenVMM clean!
78

8-
### `rustfmt`
9+
## `rustfmt`
910

10-
(enforced using [`cargo xtask fmt rustfmt`](./scripts.md#cargo-xtask))
11+
_Checked Automatically:_ **Yes** (via [`cargo xtask fmt rustfmt`](../dev_tools/xtask.md))
1112

1213
OpenVMM source must be formatted using
1314
[rustfmt](https://github.com/rust-lang/rustfmt), which automatically and
@@ -30,28 +31,32 @@ rules that are must be manually enforced:
3031
> If you're working in a file and notice that it isn't following a certain
3132
> convention, please take a moment to fix it!
3233
33-
Assuming you've followed the guide and set up `rust-analyzer` to
34-
[format on save](../ide_setup.md#enabling-format-on-save), you should rarely have
35-
to think about formatting in `.rs` files.
36-
37-
### Project-specific formatting rules
34+
Assuming you've followed the [suggested dev env setup](../getting_started/suggested_dev_env.md)
35+
and set up `rust-analyzer` to format-on-save, you should rarely have to think
36+
about formatting in `.rs` files.
3837

39-
Aside from using ecosystem-standard `rustfmt` formatting, OpenVMM also includes a
40-
handful of (automatically enforced) project-specific formatting rules.
38+
## House Rules
4139

42-
#### House Rules
40+
_Checked Automatically:_ **Yes** (via [`cargo xtask fmt house-rules`](../dev_tools/xtask.md))
4341

44-
(enforced using [`cargo xtask fmt house-rules`](./scripts.md#cargo-xtask))
42+
"House-rules" are a set of misc code lints that are specific to OpenVMM, which
43+
are enforced using a custom in-house tool:
4544

46-
These are a few minor bits of code-style that are specific to OpenVMM:
45+
- enforce the presence of the standard Microsoft copyright header
46+
- enforce in-repo crate names don't use '-' in their name (use '_' instead)
47+
- enforce Cargo.toml files don't include autogenerated "see more keys" comments
48+
- enforce Cargo.toml files don't contain author or version fields
49+
- enforce files end with a single trailing newline
50+
- deny usage of `#[repr(packed)]` (you want `#[repr(C, packed)]`)
51+
- justify usage of `cfg(target_arch = ...)` (use `guest_arch` instead!)
52+
- justify usage of `allow(unsafe_code)` with an UNSAFETY comment
4753

48-
- Enforcing the standard Microsoft copyright header at the top of each file
49-
- Enforcing single-trailing-newlines in code
50-
- Ensuring crate names do not include `-` in their name (use `_` instead!)
54+
Some of these lints are self explanatory, whereas others are described in more
55+
detail elsewhere on this page.
5156

52-
#### Unused `Cargo.toml` Dependencies
57+
## Unused `Cargo.toml` Dependencies
5358

54-
(enforced using [`cargo xtask fmt unused-deps`](./scripts.md#cargo-xtask))
59+
_Checked Automatically:_ **Yes** (via [`cargo xtask fmt unused-deps`](../dev_tools/xtask.md))
5560

5661
We have an in-repo fork of
5762
[`cargo-machete`](https://github.com/bnjbvr/cargo-machete) that ensures
@@ -61,9 +66,9 @@ Avoiding unused dependencies makes it easier to reason about what a crate is
6166
doing just by looking at its dependencies, and also helps cut-down on
6267
incremental compile times.
6368

64-
#### Formatting `Cargo.toml`
69+
## Formatting (`Cargo.toml`)
6570

66-
**Not yet enforced by `cargo xtask fmt`! Coming Soon™️**
71+
_Checked Automatically:_ **No**
6772

6873
When defining dependencies in `Cargo.toml` files, please organize dependencies
6974
into the following groups:
@@ -89,11 +94,11 @@ So, for example:
8994

9095
```toml
9196
[package]
92-
name = "hvlite"
97+
name = "openvmm"
9398

9499
[dependencies]
95100
# crate-specific subcrates
96-
hvlite_core.workspace = true
101+
openvmm_core.workspace = true
97102
...
98103

99104
# /vmcore
@@ -118,13 +123,15 @@ clap.workspace = true
118123
...
119124
```
120125

121-
## Linting (`clippy`)
126+
## Linting (via `clippy`)
127+
128+
_Checked Automatically:_ **Yes**
122129

123130
OpenVMM uses [`cargo clippy`](https://github.com/rust-lang/rust-clippy) to
124131
supplement rustc's built-in lints.
125132

126133
Assuming you've followed the guide and set up `rust-analyzer` to
127-
[use clippy](../ide_setup.md#enabling-clippy), you should see clippy lints
134+
[use clippy](../getting_started/suggested_dev_env.md#enabling-clippy), you should see clippy lints
128135
appear inline when working on Rust code.
129136

130137
The CI runs `cargo clippy` on every crate in the repo prior to building the
@@ -154,18 +161,18 @@ libc::cmsghdr {
154161
}
155162
```
156163

157-
### OpenVMM's Project-Specific `clippy` Configuration
164+
### OpenVMM's `clippy` Configuration
158165

159166
We stick fairly close to the default set of rustc / clippy lints, though there
160167
are some default lints that we've decided to disabled project wide, and other
161168
non-default lints which we've explicitly opted into.
162169

163-
See
164-
[`.cargo/config.toml`](https://github.com/microsoft/openvmm?path=/.cargo/config.toml)
170+
See the `[workspace.lints]` sections of OpenVMM's root
171+
[`Cargo.toml`](https://github.com/microsoft/openvmm?path=/Cargo.toml)
165172
for a list of globally enabled/disabled lints, along with justification as to
166173
why certain lints have been enabled/disabled.
167174

168-
## Unsafe Code
175+
## Unsafe Code Policy
169176

170177
> _Preface:_ When possible, try to avoid introducing new `unsafe` code!
171178
>
@@ -198,29 +205,24 @@ Editing a file containing unsafe code will trigger CI to automatically add the
198205
OpenVMM Unsafe Approvers group to your PR. This is to ensure that all unsafe code
199206
is audited for correctness by area experts.
200207

201-
## Additional special considerations
202-
203-
The following rules are unique to the OpenVMM codebase, and may be unfamiliar to
204-
devs coming from other Rust open-source projects.
208+
## Uses of `cfg(target_arch = ...)` must be justified
205209

206-
### Uses of `cfg(target_arch = ...)` must be justified
210+
_Checked Automatically:_ **Yes** (via [`cargo xtask fmt house-rules`](../dev_tools/xtask.md))
207211

208-
**TL;DR:** Unless you're working on something that's *genuinely* tied to the
209-
host's CPU architecture, you almost certainly want to use `cfg(guest_arch =
210-
...)` instead.
212+
Unless you're working on something that's genuinely tied to the host's CPU
213+
architecture, you should use `cfg(guest_arch = ...)` instead of `cfg(target_arch = ...)`.
211214

212-
OpenVMM is a multi-architecture VMM framework, capable of running both x86 and
213-
Aarch64 guests (and potentially others in the future).
215+
OpenVMM is a multi-architecture VMM framework, capable of running running x64
216+
guests on a x64 host, as well as Aarch64 guests on Aarch64 hosts (with the
217+
potential of adding additional platforms in the future).
214218

215-
Often times, the host architecture and the guest architecture will match,
216-
thereby enabling the use of hardware-accelerated CPU virtualization backends
217-
(e.g: KVM on Linux, WHP in Windows, etc...). That said, it's probable that at
218-
some point in the future, OpenVMM will also support *mismatched* guest/host
219-
architectures via an emulated CPU virtualization backend (akin to what QEMU
220-
does).
219+
At the moment, OpenVMM requires that the host architecture and guest
220+
architecture match. That said, it's possible that at some point in the future,
221+
OpenVMM may also support _mismatched_ guest/host architectures, via an emulated
222+
CPU virtualization backend (akin to QEMU).
221223

222-
Having an emulated CPU backend would enable
223-
OpenVMM to support such useful scenarios as:
224+
Having an emulated CPU backend would enable OpenVMM to support such useful
225+
scenarios as:
224226

225227
- running Arch64 guests on x86 machines
226228
- running x86 guests on ARM
@@ -251,7 +253,9 @@ intrinsic (such as CPUID, or a SIMD instruction), or when implementing a
251253

252254
...otherwise, use `cfg(guest_arch = ...)`!
253255

254-
### Avoid `Default` when using `zerocopy::FromZeroes`
256+
## Avoid `Default` when using `zerocopy::FromZeroes`
257+
258+
_Checked Automatically:_ **No**
255259

256260
The rule:
257261

@@ -266,7 +270,7 @@ The why:
266270
- There are plenty of types that don't have a `Default` value, but _do_ have a
267271
valid all-zero repr
268272

269-
#### Additional context
273+
### Additional context
270274

271275
As per the Rust docs for [`Default::default`](https://doc.rust-lang.org/std/default/trait.Default.html#tymethod.default):
272276

@@ -288,7 +292,7 @@ they are initially allocated as all-zero, and then get "filled in" by some
288292
secondary init code. Notably: it's quite rare for that initial "all-zero" struct
289293
to be a valid instance of the type!
290294

291-
##### Example: C FFI
295+
#### Example: C FFI
292296

293297
For example, a common pattern in C libraries might look something like:
294298

@@ -372,7 +376,9 @@ impl Default for Handle {
372376
}
373377
```
374378

375-
### Avoid Requiring `Debug` on Traits
379+
## Avoid Requiring `Debug` on Traits
380+
381+
_Checked Automatically:_ **No**
376382

377383
**TL;DR:** Don't do this:
378384

@@ -396,7 +402,9 @@ Moreover, it's usually not good form to leave tracing statements that log a
396402
struct's `Debug` representation in production. Prefer tracing just the fields
397403
you're interested in, and/or connecting objects to the `Inspect` graph.
398404

399-
### Crate Naming
405+
## Crate Naming
406+
407+
_Checked Automatically:_ **Yes** (via [`cargo xtask fmt house-rules`](../dev_tools/xtask.md))
400408

401409
**Crates must be named with underscores, not dashes and underscores used in
402410
folder names.**

0 commit comments

Comments
 (0)