Codebase — QEMU documentation

# Codebase

This section presents the various parts of QEMU and how the codebase is organized.

Beyond giving succinct descriptions, the goal is to offer links to various parts of the documentation/codebase.

Those two videos are an excellent introduction to QEMU codebase:

- QEMU Dev Starter guide - General overview

- QEMU Dev Starter guide - System mode

## Subsystems

An exhaustive list of subsystems and associated files can be found in the MAINTAINERS file.

Some of the main QEMU subsystems are:

- Accelerators

- Block devices and disk images support

- CI and Tests

- Devices & Board models

- Documentation

- GDB support

- Migration

- Monitor

- QOM (QEMU Object Model)

- System mode

- TCG (Tiny Code Generator)

- User mode (Linux & BSD)

- User Interfaces

More documentation on QEMU subsystems can be found on Internal Subsystem Information page.

## The Grand tour

We present briefly here what every folder in the top directory of the codebase contains. Hop on!

The folder name links here will take you to that folder in our gitlab repository. Other links will take you to more detailed documentation for that subsystem, where we have it. Unfortunately not every subsystem has documentation yet, so sometimes the source code is all you have.

- accel: Infrastructure and architecture agnostic code related to the various accelerators supported by QEMU (TCG, KVM, hvf, whpx, xen, nvmm, mshv). Contains interfaces for operations that will be implemented per target.

- audio: Audio (host) support.

- authz: QEMU Authorization framework.

- backends: Various backends that are used to access resources on the host (e.g. for random number generation, memory backing or cryptographic functions).

- block: Block devices and image formats implementation.

- bsd-user: BSD User mode.

- build: Where the code built goes by default. You can tell the QEMU build system to put the built code anywhere else you like.

- chardev: Various backends used by char devices.

- common-user: User-mode assembly code for dealing with signals occurring during syscalls.

- configs: Makefiles defining configurations to build QEMU.

- contrib: Community contributed devices/plugins/tools.

- crypto: Cryptographic algorithms used in QEMU.

- disas: Disassembly functions used by QEMU target code.

- docs: QEMU Documentation.

- dump: Code to dump memory of a running VM.

- ebpf: eBPF program support in QEMU. virtio-net RSS uses it.

- fpu: Floating-point software emulation.

- fsdev: VirtFS support.

- gdbstub: GDB support.

- host: Various architecture specific header files (crypto, atomic, memory operations).

- linux-headers: A subset of headers imported from Linux kernel and used for implementing KVM support and user-mode.

- linux-user: User mode implementation. Contains one folder per target architecture.

- .gitlab-ci.d: CI yaml and scripts.

- include: All headers associated to different subsystems in QEMU. The hierarchy used mirrors source code organization and naming.

- hw: Devices and boards emulation. Devices are categorized by type/protocol/architecture and located in associated subfolder.

- io: QEMU I/O channels.

- libdecnumber: Import of gcc library, used to implement decimal number arithmetic.

- migration: Migration framework.

- monitor: Monitor implementation (HMP & QMP).

- nbd: QEMU NBD (Network Block Device) server.

- net: Network (host) support.

- pc-bios: Contains pre-built firmware binaries and boot images, ready to use in QEMU without compilation.

- plugins: TCG plugins core implementation. Plugins can be found in tests and contrib folders.

- po: Translation files.

- python: Python part of our build/test system.

- qapi: QAPI implementation.

- qobject: QEMU Object implementation.

- qga: QEMU Guest agent implementation.

- qom: QEMU Object model implementation, with monitor associated commands.

- replay: QEMU Record/replay implementation.

- roms: Contains source code for various firmware and ROMs, which can be compiled if custom or updated versions are needed.

- rust: Rust integration in QEMU. It contains the new interfaces defined and associated devices using it.

- scripts: Collection of scripts used in build and test systems, and various tools for QEMU codebase and execution traces.

- scsi: Code related to SCSI support, used by SCSI devices.

- semihosting: QEMU Semihosting implementation.

- stats: Monitor stats commands implementation.

- storage-daemon: QEMU Storage daemon implementation.

- stubs: Various stubs (empty functions) used to compile QEMU with specific configurations.

- subprojects: QEMU submodules used by QEMU build system.

- system: QEMU system mode implementation (cpu, mmu, boot support).

- target: Contains code for all target architectures supported (one subfolder per arch). For every architecture, you can find accelerator specific implementations.

- tcg: TCG related code. Contains one subfolder per host supported architecture.

- tests: QEMU test suite

  - data: Data for various tests.

  - decode: Testsuite for decodetree implementation.

  - docker: Code and scripts to create containers used in CI.

  - fp: QEMU testsuite for soft float implementation.

  - functional: Functional tests (full VM boot).

  - lcitool: Generate dockerfiles for CI containers.

  - migration: Test scripts and data for Migration framework.

  - multiboot: Test multiboot functionality for x86_64/i386.

  - qapi-schema: Test scripts and data for QAPI.

  - qemu-iotests: Disk image and block tests.

  - qtest: Device emulation testing.

  - tcg: TCG related tests. Contains code per architecture (subfolder) and multiarch tests as well.

  - tsan: Suppressions for thread sanitizer.

  - uefi-test-tools: Test tool for UEFI support.

  - unit: QEMU Unit tests.

- trace: Tracing framework. Used to print information associated to various events during execution.

- ui: QEMU User interfaces.

- util: Utility code used by other parts of QEMU.