QEMU Tutorial (Version 10.0.3)

@author Jiahao Lu @ XMU [Contact: lujhcoconut@foxmail.com]

@last_update 2025/07/31

 

1. What is QEMU

QEMU is an open-source system emulator and user-mode emulator.

It can emulate various hardware platforms, such as x86, ARM, RISC-V, and PowerPC. Its main capabilities include:

In full-system emulation mode (qemu-system-*), QEMU acts as a virtual machine monitor, simulating a complete system environment that includes:

The emulated operating system runs independently of the host system, as if it were running on actual hardware provided by QEMU.

 

QEMU’s memory emulation is both fundamental and intricate, primarily reflected in the following aspects:

(i) Guest Physical Memory Emulation

(ii) Memory Mapping and Paging Mechanisms

(iii) QEMU supports advanced features including:

(iv) Host Memory Management and Security

 

Instance

-m 2048: Allocates 2GB of memory to the guest machine.

-kernel bzImage: Specifies the Linux kernel image to boot.

-hda: Sets the hard disk image (typically the root filesystem).

-nographic: Uses the terminal instead of a graphical interface (console output is redirected to the terminal).

 

2. Quick Start

 

3. Memory Management in QEMU

3.1 Detailed Explanation of Command-Line Parameters

size: Initial base memory size for the guest at boot time (unit: MB)

slots: Number of configurable memory slots (i.e., DIMM count) (can be used for hot-plugging)

maxmem: Maximum total memory supported by the guest (base memory + hot-pluggable memory)

 

BusyBox

BusyBox is an extremely lightweight and versatile collection of command-line utilities. It integrates many common Unix/Linux commands—such as ls, cp, mv, sh, grep, mount, and others—into a single executable file, with each function invoked via symlinks or command-line parameters corresponding to the specific command.

 

 

Static compilation example of BusyBox

This will generate a statically compiled BusyBox and install it to _install/. Verify it again using the following command.

Correct output should be like this

Then

These are typically mounted by the init script during early boot for kernel–user space interaction.

QEMU Start

outputs:

NUMA Support

outputs:

Good Habit

1. Efficiently retrieving error messages during compilation