QEMU
Contents
QEMU
QEMU (short for Quick EMUlator) is a versatile and widely used free and open-source virtualization and emulation tool. It can run operating systems and programs for one CPU architecture on a machine with a different CPU architecture.
QEMU has two main modes of operation:
1. System Emulation: In this mode, QEMU emulates an entire computer system, including a CPU, memory, and various hardware devices. This allows you to run a complete OS (like Linux, Windows, BSD) designed for one type of CPU (e.g., ARM) on a machine with a completely different type of CPU (e.g., x86). This is achieved through binary translation, where QEMU translates the guest CPU instructions into instructions that your host CPU can understand. This process is quite flexible, but because it involves translation, it can be relatively slow compared to running an OS designed for your native CPU.
2. User-mode Emulation: In this mode, QEMU can run individual programs (not a full OS) compiled for one Linux CPU architecture directly on a Linux system with a different CPU architecture. For example, you could run an ARM Linux program on an x86 Linux machine. This is useful for cross-compiling or testing software for different architectures.
QEMU with KVM (Hardware Accelerated Virtualization)
While QEMU can emulate an entire system on its own (using binary translation, which can be slow), its most common and fastest use case for full system virtualization on Linux is when it's used together with KVM.
Remember that KVM is the part of the Linux kernel that turns the kernel into a hypervisor and allows the guest OS's CPU instructions to run directly on the host CPU using hardware virtualization extensions.
- KVM handles the CPU and Memory Virtualization: KVM uses the hardware virtualization extensions to provide the core, high-performance CPU and memory virtualization for the guest [[Operating system|OS)]. This is why VMs are very fast when KVM is enabled.
- QEMU Handles Device Emulation and Management: QEMU runs in user-space (outside the kernel) and is responsible for emulating the virtual hardware devices that the guest OS sees (such as virtual network cards, virtual storage controllers, USB controllers, graphics cards, etc.). QEMU also handles the overall management of the VM, including starting and stopping it, configuring its virtual hardware, managing storage images, creating snapshots, and handling input/output.
So, think of KVM as providing the raw power and speed for running the guest CPU, while QEMU provides all the "virtual hardware" and the management layer that makes the VM a complete, usable computer system. They work together to provide fast and flexible virtualization on Linux.
Key Capabilities
QEMU's design gives it several powerful capabilities:
- **Wide Architecture Support:** QEMU can emulate a large number of CPU architectures (x86, ARM, PowerPC, SPARC, MIPS, etc.) and can also run on many different host architectures.
- **Device Emulation:** It can emulate a wide range of virtual hardware devices, allowing many different operating systems to run as guests.
- **Various Disk Image Formats:** Supports different file formats for VM disk images (like QCOW2, VDI, VMDK).
- **Snapshots:** Ability to save the state of a VM at a specific point in time.
- **Live Migration:** When used with KVM and management tools, QEMU supports moving a running VM from one physical host to another with minimal downtime.
Usage Scenarios
QEMU is used in diverse ways:
- **Cross-Architecture Development/Testing:** Running OSs or programs compiled for different CPU architectures.
- **Virtualization on Linux:** Its most common use is providing the user-space and device emulation parts for KVM on Linux servers (like seedboxes and VPSs) and desktops.
- **Forensics and Security Research:** Running suspicious software or operating systems in an isolated, controlled environment.
- **Embedded System Development:** Emulating hardware environments for developing software for embedded devices.
In summary, QEMU is a powerful tool that can either fully emulate a computer system (useful but slower) or work together with KVM on Linux to provide fast, hardware-accelerated virtualization by handling the virtual devices and management tasks.
See Also
- Virtualization
- Emulation
- KVM
- Virtual machine
- Hypervisor
- Binary translation
- Libvirt (A management API and tools for KVM/QEMU and other virtualizers)
References
- Template:Cite web - The primary source for information about QEMU.
- Template:Cite web - Provides detailed information about QEMU's features and usage.
- Template:Cite web - Explains KVM and its relationship with user-space tools like QEMU.
- Template:Cite web - Explanation of QEMU, often in the context of KVM, from a major Linux vendor.