qemu · October 4, 2025·

QEMU Installation

Before start this series, we need to understand difference between QEMU installation and building from source. We need to know under what conditions installing QEMU is sufficient, or in which situations we must compile it from source code.

The primary distinction between installing QEMU via pre-built packages and building it from source code lies in the method of acquisition, level of customization, and effort involved. Installation typically refers to obtaining and deploying pre-compiled binaries from a package manager. In contrast, building from source involves downloading the source code, configuring it according to specific needs, compiling it, and then installing the resulting binaries.

For scenarios involving the installation of Linux-style operating systems (e.g., Ubuntu, Fedora, or Debian derivatives) and conducting high-level testing—such as verifying application compatibility, kernel behavior, or system performance in a virtual environment—it is generally more efficient and logical to opt for installation via a package manager. This approach minimizes setup complexity, ensures compatibility with the host system, and leverages pre-optimized binaries, allowing users to focus on testing rather than compilation intricacies.

Why building from source enables custom machines and devices; QEMU's architecture, based on the QEMU Object Model (QOM), facilitates modular extensions through source code modifications. Pre-built installations provide fixed binaries, limiting users to existing emulated hardware. In contrast, building from source permits direct integration of custom code, enabling the creation of new virtual machines (e.g., custom boards with specific CPUs and peripherals) or individual devices (e.g., specialized ROMs, interrupts, or I/O modules). This is essential for scenarios such as hardware prototyping, reverse engineering, embedded system simulation, or research involving non-standard architectures like custom RISC-V or ARM variants.

Installation On Ubuntu

sudo apt update
sudo apt install -y qemu-system qemu-utils qemu-user qemu-user-static
sudo apt install -y virt-manager libvirt-daemon-system libvirt-clients

Installation On Fedora/RHEL

sudo dnf -y install qemu-kvm qemu-img virt-manager libvirt-daemon libvirt-daemon-config-network
sudo systemctl enable --now libvirtd

Installation On MacOS

brew install qemu

Check installation

qemu-system-x86_64 --version
qemu-img --version

QEMU Building From Source

Dependencies (Ubuntu)

sudo apt update
sudo apt install -y git build-essential python3 meson ninja-build pkg-config \
  libglib2.0-dev libpixman-1-dev libfdt-dev zlib1g-dev libcapstone-dev libssh-dev \
  libsdl2-dev libgtk-3-dev libspice-server-dev

Dependencies (Fedora/RHEL)

sudo dnf -y groupinstall "Development Tools"
sudo dnf -y install git python3 meson ninja-build pkgconf-pkg-config \
  glib2-devel pixman-devel libfdt-devel zlib-devel capstone-devel libssh-devel \
  SDL2-devel gtk3-devel spice-server-devel

Dependencies (MacOS)

brew install pkg-config glib pixman meson ninja python3 zlib libfdt \
  capstone libssh sdl2 gtk+3 spice-server dtc libssh

Building QEMU

git clone https://git.qemu.org/git/qemu.git
cd qemu
./configure --target-list=arm-softmmu       #<-- This is the target list for arm architecture
./configure --target-list=aarch64-softmmu   #<-- This is the target list for aarch64 architecture
./configure --target-list=x86_64-softmmu    #<-- This is the target list for x86_64 architecture
./configure --target-list=riscv64-softmmu   #<-- This is the target list for riscv64 architecture
make -j$(nproc)
sudo make install

Usage Examples

| Command                                   | Purpose                                   |
| ----------------------------------------- | ----------------------------------------- |
| $ qemu-system-aarch64                     | Launch AArch64 virtual machine            |
| $ qemu-img create -f qcow2 disk.qcow2 10G | Create a disk image                       |
| $ qemu-system-aarch64 -accel tcg -m 1024  | Run AArch64 guest with software emulation |
| $ qemu-system-aarch64 -accel kvm -m 2048  | Run with KVM acceleration                 |
| $ qemu-img info disk.qcow2                | Inspect disk image                        |

References