QEMU

From Pulsed Media Wiki

QEMU

QEMU (Quick EMUlator) is a versatile and widely used free and open-source tool for virtualization and emulation. It can run operating systems and programs designed for one type of CPU on a machine with a different CPU.

QEMU operates in two main ways:

System Emulation: In this mode, QEMU acts as a complete virtual computer, including a CPU, memory, and various hardware devices. This lets you run a full operating system (like Linux, Windows, or BSD) meant for one CPU type (e.g., ARM) on a machine with a totally different CPU (e.g., x86). It does this by translating the guest CPU's instructions for your host CPU, which is flexible but can be relatively slow.

User-mode Emulation: Here, QEMU runs individual programs (not a full OS) compiled for one Linux CPU architecture directly on a Linux system with a different architecture. For example, you could run an ARM Linux program on an x86 Linux machine. This is useful for testing software for different CPU types.

QEMU with KVM (Hardware Accelerated Virtualization)

While QEMU can emulate a whole system by itself (which can be slow), its most common and fastest use for full system virtualization on Linux is when paired with KVM.

Remember, KVM is the part of the Linux kernel that turns the kernel into a hypervisor. It allows the guest operating system's CPU instructions to run directly on your host CPU using special hardware features.

When QEMU is used with KVM:

KVM handles the CPU and Memory Virtualization: KVM uses your CPU's hardware features to provide fast, core virtualization for the guest OS's CPU and memory. This is why virtual machines are very quick when KVM is enabled. QEMU handles Device Emulation and Management: QEMU runs outside the kernel (in "user-space") and is responsible for pretending to be all the virtual hardware devices the guest OS needs (like virtual network cards, storage controllers, USB, graphics cards). QEMU also manages the overall VM, including starting/stopping it, configuring its virtual hardware, and managing disk images. So, think of KVM as providing the raw power and speed for running the guest's CPU, while QEMU provides all the "virtual hardware" and the management layer that makes the VM a complete, usable computer system. They work together for fast and flexible virtualization on Linux.

Key Capabilities

QEMU's design offers powerful features:

Wide Architecture Support: Can emulate many CPU architectures (x86, ARM, PowerPC, etc.) and run on many different host architectures. Device Emulation: Can emulate a wide range of virtual hardware, allowing many different operating systems to run as guests. Various Disk Image Formats: Supports different file formats for VM disk images. Snapshots: Ability to save a VM's state at a specific moment. Live Migration: When used with KVM and management tools, QEMU can move a running VM from one physical computer to another with minimal downtime.

Usage Scenarios

QEMU is used in diverse ways:

Cross-Architecture Development/Testing: Running operating systems or programs for different CPU architectures. Virtualization on Linux: Its most common use is providing the virtual devices and management for KVM on Linux servers (like seedboxes and VPSs) and desktops. Forensics and Security Research: Running suspicious software or operating systems in a safe, isolated environment. Embedded System Development: Emulating hardware for developing software for embedded devices. In summary, QEMU is a powerful tool that can either fully emulate a computer system (flexible but slower) or work with KVM on Linux to provide fast, hardware-accelerated virtualization by handling virtual devices and management tasks.

See Also