# google/crosvm architecture

> Architecture diagram of the GitHub repository google/crosvm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google/crosvm
- Repository: https://github.com/google/crosvm

## Overview

1. **What the repository is**
   - This is the `crosvm` virtualization stack. The top-level binary in `src/` is the VM monitor/orchestrator, while most functionality is split into reusable crates for memory, devices, async I/O, hypervisor backends, and platform-specific integration.

2. **Entry point and orchestration layer**
   - `src/main.rs` and `src/crosvm/*` implement the host-facing control plane: CLI/config parsing, VM setup, device selection, and lifecycle management.
   - `src/sys/linux/*` and `src/sys/windows/*` hold the platform-specific launch paths and host integration logic.
   - This layer is the coordinator that wires together hypervisor, memory, kernel loading, device models, sandboxing, and control APIs.

3. **Guest boot and machine construction**
   - `kernel_loader`, `kernel_cmdline`, `cros_fdt`, `acpi_tables`, `x86_64`, `aarch64`, and `riscv64` are responsible for preparing guest boot inputs:
     - loading kernels / boot images,
     - constructing kernel command lines,
     - building FDT/ACPI/SMBIOS/boot tables,
     - architecture-specific boot metadata.
   - On x86, `x86_64` also covers boot parameters, GDT/interrupt setup, and platform tables.
   - This forms the boundary between host initialization and the guest’s initial boot state.

4. **Hypervisor abstraction**
   - `hypervisor` is the backend abstraction for VM creation and vCPU execution.
   - It supports multiple providers: KVM, WHPX, HAXM, Gunyah, GenieZone, and Halla, with per-arch implementations under `hypervisor/src/*`.
   - `kvm_sys`, `vfio_sys`, and `virtio_sys` are low-level bindgen/syscall crates used by higher layers where direct kernel or device ABI access is required.
   - In the diagram, this is the hardware-acceleration boundary: crosvm talks to a hypervisor backend, which in turn talks to the kernel/OS virtualization APIs.

5. **Guest memory and address-space management**
   - `vm_memory` provides guest RAM mappings, guest-address types, and udmabuf integration.
   - `resources` provides address allocators for guest RAM windows, MMIO ranges, PCI addresses, and related host-side resource planning.
   - `swap`, `disk`, and some device crates consume these abstractions when they need direct guest memory access or host-backed buffers.
   - This subsystem is the shared substrate used by hypervisor, device emulation, and boot image placement.

6. **Device model: the main emulation surface**
   - `devices` is the largest subsystem and contains the emulated hardware model.
   - It includes:
     - legacy/platform devices: ACPI, CMOS, PIT, serial, power, TPM, debug console;
     - interrupt controllers and irqchips: APIC, IOAPIC, PIC, KVM-backed, WHPX, userspace, and platform-specific variants;
     - PCI/PCIe infrastructure: root complex, bridges, hotplug, MSI/MSI-X, configuration space, VFIO passthrough;
     - virtio device implementations.
   - The core architecture diagram should show `devices` hanging off the guest buses and interrupt paths, not directly off the CLI.

7. **Virtio I/O path**
   - Most guest-visible modern devices live under `devices/src/virtio/*`.
   - This includes block, net, fs, gpu, input, rng, balloon, console, vsock, pmem, scsi, snd, video, p9, tpm, and vhost/vhost-user adapters.
   - The data flow is generally: guest driver → virtqueue descriptors → device backend/worker → host resource or service → completion interrupt back to the guest.
   - Shared queue handling lives in `devices/src/virtio/queue/*`, `descriptor_*`, and `interrupt.rs`.

8. **Async/event-driven execution**
   - `cros_async` is the async runtime and event orchestration layer used by devices and I/O-heavy components.
   - It provides executors, timers, polling/event sources, wakers, queueing, and blocking work pools with Linux and Windows implementations.
   - `base`, `base_tokio`, and `io_uring` support lower-level event sources, descriptors, wait contexts, tubes, timers, and Linux async I/O integration.
   - In the diagram, this is the internal scheduler/event loop that connects device workers to host kernel events and guest-facing queues.

9. **Sandboxing and process isolation**
   - `jail` implements the Linux process isolation layer using Minijail and seccomp policies.
   - The policy files under `jail/seccomp/*` are per-device and per-arch, which matches crosvm’s process-per-device security model.
   - `base` contains the IPC, descriptor, tube, notifier, and worker-thread primitives used to connect sandboxed child processes back to the main VM process.
   - This is an important architectural boundary: trusted orchestration in the parent, restricted device workers in jailed subprocesses.

10. **Host/device communication and control plane**
   - `vm_control`, `crosvm_control`, `crosvm_cli`, and parts of `base` provide control APIs and IPC plumbing for external clients.
   - The host management path is separate from the guest datapath: external tools issue commands to crosvm, which then mutates VM state or forwards actions to device workers.
   - `tube_transporter`, `base::tube`, and related IPC layers are the main internal transport for this control path.

11. **Storage, networking, and filesystem backends**
   - `disk` handles raw, qcow2, Android sparse, GPT, and zstd-backed disk images.
   - `net_util`, `net_sys`, `vhost`, and `vhost`-related device code cover tap/slirp networking and vhost acceleration.
   - `fuse`, `ext2`, and `common/audio_streams` support specialized storage/filesystem and audio flows where the device model delegates to host-side services or shared-memory backends.
   - These are backend libraries rather than the VM orchestrator itself, so they sit behind the virtio devices.

12. **Graphics, input, and multimedia stack**
   - `gpu_display`, `media`, `media/ffmpeg`, `media/libvda`, `android_audio`, and `win_audio` provide platform and codec backends for GPU/audio/video features.
   - `devices/src/virtio/gpu`, `.../video`, `.../snd`, and `gpu_display` connect the guest’s graphics/audio/video queues to host rendering, encoding/decoding, or audio APIs.
   - External services and libraries matter here: Wayland/X11/Windows UI surfaces, FFmpeg, ChromeOS `libvda`, CRAS, and Android AAudio are part of the runtime architecture for those devices.

13. **Platform-specific and vendor-specific virtualization paths**
   - Android and ChromeOS integration live across `arch`, `common`, `system_api`, `power_monitor`, and `README.chromeos.md`-related paths.
   - Vendor hypervisors and ARM-specific flows are split into `aarch64_sys_reg`, `geniezone`, `gunyah`, `halla`, and their corresponding device/irqchip support.
   - The repo is explicitly multi-platform: Linux is the primary host, but there is substantial Windows support and multiple ARM hypervisor backends.

14. **Testing, end-to-end validation, and tooling**
   - `e2e_tests` is the guest/VM integration test harness with dedicated guest images, boot flows, and workload benchmarks.
   - `fuzz` covers protocol and parser surfaces such as virtqueues, block/FS, USB descriptors, and QCOW.
   - `infra`, `tools`, and `docs/book` contain build/test automation and architecture docs, but they are support systems rather than runtime components.
   - For an architecture diagram, these are best shown as validation/tooling around the core VM stack, not in the hot path.

15. **Overall data flow to capture in a diagram**
   - External user/tooling invokes the crosvm binary or control API.
   - crosvm constructs guest boot state, allocates memory/resources, and instantiates a hypervisor VM.
   - vCPUs run in the hypervisor backend while device models run in-process or in jailed child processes.
   - Guest I/O exits through virtio/PCI/MMIO/IRQ paths into device backends, which use async I/O, host services, or external libraries, then signal completion back into the guest.
   - The major architectural boundaries are: host control plane vs guest datapath, parent process vs jailed device workers, and device abstractions vs backend-specific implementations.

Main entry points: [`src/crosvm`](https://github.com/google/crosvm/tree/main/src/crosvm) (VM setup), [`devices`](https://github.com/google/crosvm/tree/main/devices) (Device model), [`hypervisor`](https://github.com/google/crosvm/tree/main/hypervisor) (Hypervisor), [`jail`](https://github.com/google/crosvm/tree/main/jail) (Sandboxing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_control["Control Plane"]
  node_src_main["crosvm binary<br/>entry/orchestrator<br/>[main.rs]"]
  node_src_crosvm["VM setup<br/>orchestration"]
  node_vm_control["Control API<br/>ipc/control"]
end

subgraph group_g_boot["Guest Boot"]
  node_kernel_loader["Kernel loader<br/>boot loader"]
  node_kernel_cmdline["Cmdline<br/>boot config"]
  node_cros_fdt["FDT builder<br/>boot tables"]
  node_acpi_tables["ACPI tables<br/>boot tables"]
  node_x86_64["x86 boot<br/>arch boot"]
end

subgraph group_g_core["Core Substrate"]
  node_vm_memory[("Guest memory<br/>memory substrate")]
  node_resources["Allocators<br/>resource planning"]
  node_cros_async["Async runtime<br/>event loop"]
  node_base["IPC base<br/>primitives"]
  node_jail["Sandboxing<br/>isolation"]
end

subgraph group_g_hypervisor["Hypervisor Backends"]
  node_hypervisor["Hypervisor<br/>vm backend"]
  node_kvm_sys[("KVM ABI<br/>sys/abi")]
  node_vfio_sys[("VFIO ABI<br/>sys/abi")]
  node_virtio_sys[("Virtio ABI<br/>sys/abi")]
end

subgraph group_g_devices["Device Model"]
  node_devices["Device model<br/>emulation core"]
end

subgraph group_g_media["Host Backends"]
  node_gpu_display["Display stack<br/>graphics backend"]
  node_media["Media codecs<br/>codec/backend"]
  node_net_util["Network host<br/>network backend"]
  node_disk["Disk backends<br/>storage backend"]
  node_fuse["FUSE service<br/>fs backend"]
  node_ext2["Ext2 tools<br/>fs image"]
end

subgraph group_g_platform["Platform Layers"]
  node_src_sys_linux["Linux host<br/>host integration<br/>[linux.rs]"]
  node_src_sys_windows["Windows host<br/>host integration<br/>[windows.rs]"]
  node_arch["Arch support<br/>platform arch"]
end

subgraph group_g_validation["Validation & Tooling"]
  node_e2e_tests["E2E tests<br/>integration tests"]
  node_fuzz["Fuzzing<br/>fuzz targets"]
  node_docs_book["Docs<br/>documentation"]
end

node_src_main -->|"starts"| node_src_crosvm
node_src_crosvm -->|"loads"| node_kernel_loader
node_src_crosvm -->|"builds"| node_kernel_cmdline
node_src_crosvm -->|"assembles"| node_cros_fdt
node_src_crosvm -->|"assembles"| node_acpi_tables
node_src_crosvm -->|"specializes"| node_x86_64
node_src_crosvm -->|"allocates"| node_vm_memory
node_src_crosvm -->|"plans"| node_resources
node_src_crosvm -->|"creates VM"| node_hypervisor
node_src_crosvm -->|"wires devices"| node_devices
node_src_crosvm -->|"isolates"| node_jail
node_src_crosvm -->|"exposes"| node_vm_control
node_hypervisor -->|"uses"| node_kvm_sys
node_hypervisor -->|"uses"| node_vfio_sys
node_hypervisor -->|"uses"| node_virtio_sys
node_devices -->|"drives"| node_cros_async
node_devices -->|"communicates"| node_base
node_devices -->|"maps"| node_vm_memory
node_devices -->|"reserves"| node_resources
node_devices -->|"renders via"| node_gpu_display
node_devices -->|"streams via"| node_media
node_devices -->|"networking"| node_net_util
node_devices -->|"storage"| node_disk
node_devices -->|"filesystem"| node_fuse
node_disk -->|"shares buffers"| node_vm_memory
node_cros_async -->|"builds on"| node_base
node_jail -->|"uses"| node_base
node_src_sys_linux -->|"launches"| node_jail
node_src_sys_windows -->|"integrates"| node_hypervisor
node_arch -->|"extends"| node_src_crosvm
node_e2e_tests -.->|"validates"| node_src_main
node_fuzz -.->|"hardens"| node_devices
node_docs_book -.->|"documents"| node_src_crosvm

click node_src_main "https://github.com/google/crosvm/blob/main/src/main.rs"
click node_src_crosvm "https://github.com/google/crosvm/tree/main/src/crosvm"
click node_vm_control "https://github.com/google/crosvm/tree/main/vm_control"
click node_kernel_loader "https://github.com/google/crosvm/tree/main/kernel_loader"
click node_kernel_cmdline "https://github.com/google/crosvm/tree/main/kernel_cmdline"
click node_cros_fdt "https://github.com/google/crosvm/tree/main/cros_fdt"
click node_acpi_tables "https://github.com/google/crosvm/tree/main/acpi_tables"
click node_x86_64 "https://github.com/google/crosvm/tree/main/x86_64"
click node_vm_memory "https://github.com/google/crosvm/tree/main/vm_memory"
click node_resources "https://github.com/google/crosvm/tree/main/resources"
click node_cros_async "https://github.com/google/crosvm/tree/main/cros_async"
click node_base "https://github.com/google/crosvm/tree/main/base"
click node_jail "https://github.com/google/crosvm/tree/main/jail"
click node_hypervisor "https://github.com/google/crosvm/tree/main/hypervisor"
click node_kvm_sys "https://github.com/google/crosvm/tree/main/kvm_sys"
click node_vfio_sys "https://github.com/google/crosvm/tree/main/vfio_sys"
click node_virtio_sys "https://github.com/google/crosvm/tree/main/virtio_sys"
click node_devices "https://github.com/google/crosvm/tree/main/devices"
click node_gpu_display "https://github.com/google/crosvm/tree/main/gpu_display"
click node_media "https://github.com/google/crosvm/tree/main/media"
click node_net_util "https://github.com/google/crosvm/tree/main/net_util"
click node_disk "https://github.com/google/crosvm/tree/main/disk"
click node_fuse "https://github.com/google/crosvm/tree/main/fuse"
click node_ext2 "https://github.com/google/crosvm/tree/main/ext2"
click node_src_sys_linux "https://github.com/google/crosvm/blob/main/src/sys/linux.rs"
click node_src_sys_windows "https://github.com/google/crosvm/blob/main/src/sys/windows.rs"
click node_arch "https://github.com/google/crosvm/tree/main/arch"
click node_e2e_tests "https://github.com/google/crosvm/tree/main/e2e_tests"
click node_fuzz "https://github.com/google/crosvm/tree/main/fuzz"
click node_docs_book "https://github.com/google/crosvm/tree/main/docs/book"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_src_main,node_src_crosvm,node_vm_control,node_src_sys_linux,node_src_sys_windows,node_arch toneBlue
class node_kernel_loader,node_kernel_cmdline,node_cros_fdt,node_acpi_tables,node_x86_64,node_e2e_tests,node_fuzz,node_docs_book toneAmber
class node_vm_memory,node_resources,node_cros_async,node_base,node_jail toneMint
class node_hypervisor,node_kvm_sys,node_vfio_sys,node_virtio_sys toneRose
class node_devices toneIndigo
class node_gpu_display,node_media,node_net_util,node_disk,node_fuse,node_ext2 toneTeal
```

## Components

### Control Plane

CLI, orchestration, and external control APIs.

- [crosvm binary](https://github.com/google/crosvm/blob/main/src/main.rs): entry/orchestrator · Top-level VM monitor entry point and process coordinator. · `src/main.rs`
- [VM setup](https://github.com/google/crosvm/tree/main/src/crosvm): orchestration · CLI/config parsing, VM construction, device selection, and lifecycle control. · `src/crosvm`
- [Control API](https://github.com/google/crosvm/tree/main/vm_control): ipc/control · External control surface for managing VMs and device state. · `vm_control`

### Guest Boot

Kernel loading and machine-setup inputs.

- [Kernel loader](https://github.com/google/crosvm/tree/main/kernel_loader): boot loader · Loads kernels and boot images for guest startup. · `kernel_loader`
- [Cmdline](https://github.com/google/crosvm/tree/main/kernel_cmdline): boot config · Builds guest kernel command lines. · `kernel_cmdline`
- [FDT builder](https://github.com/google/crosvm/tree/main/cros_fdt): boot tables · Constructs device tree overlays and related boot metadata. · `cros_fdt`
- [ACPI tables](https://github.com/google/crosvm/tree/main/acpi_tables): boot tables · Builds ACPI/SMBIOS/firmware tables for guests. · `acpi_tables`
- [x86 boot](https://github.com/google/crosvm/tree/main/x86_64): arch boot · x86-specific boot parameters, GDT, interrupts, and platform tables. · `x86_64`

### Core Substrate

Shared memory, async, IPC, and isolation primitives.

- [Guest memory](https://github.com/google/crosvm/tree/main/vm_memory): memory substrate · Guest RAM mappings, address types, and udmabuf integration. · `vm_memory`
- [Allocators](https://github.com/google/crosvm/tree/main/resources): resource planning · Guest RAM, MMIO, PCI, and host-side address allocation. · `resources`
- [Async runtime](https://github.com/google/crosvm/tree/main/cros_async): event loop · Executors, timers, polling, blocking work pools, and wakers. · `cros_async`
- [IPC base](https://github.com/google/crosvm/tree/main/base): primitives · Descriptors, tubes, wait contexts, worker threads, and host IPC primitives. · `base`
- [Sandboxing](https://github.com/google/crosvm/tree/main/jail): isolation · Minijail and seccomp-based device worker isolation. · `jail`

### Hypervisor Backends

VM and vCPU providers plus low-level ABI bindings.

- [Hypervisor](https://github.com/google/crosvm/tree/main/hypervisor): vm backend · Backend abstraction for VM creation and vCPU execution. · `hypervisor`
- [KVM ABI](https://github.com/google/crosvm/tree/main/kvm_sys): sys/abi · Low-level KVM bindings used by the hypervisor layer. · `kvm_sys`
- [VFIO ABI](https://github.com/google/crosvm/tree/main/vfio_sys): sys/abi · Low-level VFIO bindings for device passthrough and I/O access. · `vfio_sys`
- [Virtio ABI](https://github.com/google/crosvm/tree/main/virtio_sys): sys/abi · Low-level virtio and vhost ABI definitions. · `virtio_sys`

### Device Model

Emulated hardware, buses, interrupts, and virtio.

- [Device model](https://github.com/google/crosvm/tree/main/devices): emulation core · Emulated hardware, buses, irqchips, PCI, and virtio frontends. · `devices`

### Host Backends

Host-side services for graphics, audio, networking, and storage.

- [Display stack](https://github.com/google/crosvm/tree/main/gpu_display): graphics backend · Host display integration for rendering and window-system surfaces. · `gpu_display`
- [Media codecs](https://github.com/google/crosvm/tree/main/media): codec/backend · FFmpeg and libvda-backed audio/video encode and decode support. · `media`
- [Network host](https://github.com/google/crosvm/tree/main/net_util): network backend · Tap and slirp host networking support. · `net_util`
- [Disk backends](https://github.com/google/crosvm/tree/main/disk): storage backend · Raw, qcow2, sparse, GPT, and zstd-backed disk image handling. · `disk`
- [FUSE service](https://github.com/google/crosvm/tree/main/fuse): fs backend · Filesystem server and mount-side host service support. · `fuse`
- [Ext2 tools](https://github.com/google/crosvm/tree/main/ext2): fs image · Ext2 filesystem construction and manipulation utilities. · `ext2`

### Platform Layers

Host- and architecture-specific integration paths.

- [Linux host](https://github.com/google/crosvm/blob/main/src/sys/linux.rs): host integration · Primary Linux launch path and host integration logic. · `src/sys/linux.rs`
- [Windows host](https://github.com/google/crosvm/blob/main/src/sys/windows.rs): host integration · Windows launch path and host integration logic. · `src/sys/windows.rs`
- [Arch support](https://github.com/google/crosvm/tree/main/arch): platform arch · Architecture-specific host helpers and platform hooks. · `arch`

### Validation & Tooling

Integration tests, fuzzing, and docs/tooling around the runtime.

- [E2E tests](https://github.com/google/crosvm/tree/main/e2e_tests): integration tests · Guest boot and workload validation harness. · `e2e_tests`
- [Fuzzing](https://github.com/google/crosvm/tree/main/fuzz): fuzz targets · Parser and protocol fuzz coverage for critical surfaces. · `fuzz`
- [Docs](https://github.com/google/crosvm/tree/main/docs/book): documentation · Architecture and usage documentation for the repository. · `docs/book`

## Connections

- crosvm binary → VM setup: starts · The binary delegates VM orchestration to the crosvm control layer.
- VM setup → Kernel loader: loads · Boot pipeline loads guest kernel or boot image.
- VM setup → Cmdline: builds · Constructs guest command line and boot parameters.
- VM setup → FDT builder: assembles · Prepares device-tree-based boot metadata where needed.
- VM setup → ACPI tables: assembles · Prepares ACPI and SMBIOS tables for the guest.
- VM setup → x86 boot: specializes · x86 host/guest boot details are layered in for x86 machines.
- VM setup → Guest memory: allocates · Sets up guest memory mappings and placement.
- VM setup → Allocators: plans · Allocates MMIO, PCI, and other guest resources.
- VM setup → Hypervisor: creates VM · Instantiates the backend VM and vCPU execution context.
- VM setup → Device model: wires devices · Constructs the guest device model and bus topology.
- VM setup → Sandboxing: isolates · Moves selected device workers into sandboxed subprocesses.
- VM setup → Control API: exposes · Publishes control APIs for external clients.
- Hypervisor → KVM ABI: uses · KVM is one backend ABI used for hardware acceleration.
- Hypervisor → VFIO ABI: uses · VFIO is used for device passthrough paths.
- Hypervisor → Virtio ABI: uses · Virtio and vhost ABI support underpin backend integrations.
- Device model → Async runtime: drives · Device workers and I/O paths are event-driven.
- Device model → IPC base: communicates · Uses tubes, descriptors, and IPC primitives for coordination.
- Device model → Guest memory: maps · Devices consume guest memory for DMA and shared buffers.
- Device model → Allocators: reserves · Device placement consumes address allocation results.
- Device model → Display stack: renders via · Graphics devices connect to host display backends.
- Device model → Media codecs: streams via · Video and audio devices delegate to codec/media backends.
- Device model → Network host: networking · Network devices depend on host tap/slirp support.
- Device model → Disk backends: storage · Block and related storage devices rely on disk backends.
- Device model → FUSE service: filesystem · Filesystem-related device paths can delegate to FUSE services.
- Disk backends → Guest memory: shares buffers · Image I/O and guest-facing buffers interact through memory mappings.
- Async runtime → IPC base: builds on · Async runtime sits on top of the lower-level IPC and waiting primitives.
- Sandboxing → IPC base: uses · Sandboxed workers are connected back to the parent process through base IPC.
- Linux host → Sandboxing: launches · Linux path performs process isolation and device worker setup.
- Windows host → Hypervisor: integrates · Windows path coordinates the host VM backend and launch flow.
- Arch support → VM setup: extends · Architecture helpers feed the orchestration and platform setup layer.
- E2E tests → crosvm binary: validates · Integration tests exercise the full crosvm execution path.
- Fuzzing → Device model: hardens · Fuzzing targets cover device and protocol parsing surfaces.
- Docs → VM setup: documents · Architecture docs explain the runtime and control-plane design.
