QEMU

QEMU
Original author(s) Fabrice Bellard
Developer(s) QEMU team:
Fabrice Bellard, Paul Brook, et al.
Stable release 1.0[1] / December 1, 2011; 2 months ago (2011-12-01)
Operating system Cross-platform
Type Emulator
License GNU GPL version 2
Website http://www.qemu.org/

QEMU is a processor emulator that relies on dynamic binary translation to achieve a reasonable speed while being easy to port on new host CPU architectures.

In conjunction with CPU emulation, it also provides a set of device models, allowing it to run a variety of unmodified guest operating systems; it can thus be viewed as a hosted virtual machine monitor. It also provides an accelerated mode for supporting a mixture of binary translation (for kernel code) and native execution (for user code), in the same fashion as VMware Workstation and VirtualBox. QEMU can also be used purely for CPU emulation for user level processes, allowing applications compiled for one architecture to be run on another.

Contents

Licensing

QEMU was written by Fabrice Bellard and is free software. Various parts are released under different GNU General Public License version 2-compatible licenses. These include the GNU Lesser General Public License (GNU LGPL) or permissive licenses such as the BSD license.[2] There is an option to use the proprietary FMOD library when running on Windows, which, if used, disqualifies the use of a single Open Source software license. However, the default is to use DirectSound.

Details

QEMU has two operating modes:[3]

User mode emulation
In this mode QEMU runs single Linux or Darwin/Mac OS X programs that were compiled for a different CPU. System calls are thunked for endianness and for 32/64 bit mismatches. Fast cross-compilation and cross-debugging are the main targets for user-mode emulation.
Computer emulation
In this mode QEMU emulates a full computer system, including peripherals. It can be used to provide virtual hosting of several virtual computers on a single computer. QEMU can boot many guest operating systems, including Linux, Solaris, Microsoft Windows, DOS, and BSD [1]; it supports emulating several hardware platforms, including x86, x86-64, ARM, Alpha, ETRAX CRIS, MIPS, MicroBlaze, PowerPC and SPARC.

Features

QEMU can save and restore the state of the virtual machine with all programs running. Guest operating systems do not need to be patched to run safely under QEMU.

QEMU supports the emulation of various architectures, including IA-32 (x86) PCs, x86-64 PCs, MIPS R4000, Sun's SPARC sun4m, Sun's SPARC sun4u, ARM development boards (Integrator/CP and Versatile/PB), SH4 SHIX board, PowerPC (PReP and Power Macintosh), ETRAX CRIS and MicroBlaze architectures. The QEMU homepage provides a complete list of supported architectures.

The virtual machine can be equipped with many types of hardware. Some of these are: hard disks, CD-ROM drives, network cards, sound chips, and USB devices. USB devices can be completely emulated (mass storage from image files, input devices), or the host's USB devices can be used (however, this requires administrator privileges and does not work with all devices).

Virtual hard disk images can be stored in a special format (qcow or qcow2) that only takes up disk space that the guest OS actually uses. This way, an emulated 120 GiB disk can still take up just several hundred megabytes on the host. The QCOW2 format also allows the creation of overlay images that record the difference to another base image file which is not modified. This can be useful to have the possibility of reverting the disk's contents to an earlier state. For example, a base image could hold a fresh install of an operating system that is known to work, and the overlay images are worked with. Should the guest system be unusable (virus attack, accidental system destruction, ...), the overlay can be deleted and recreated.

QEMU can emulate network cards (of different models) which share the host system's connectivity by doing network address translation, effectively allowing the guest to use the same network as the host. The virtual network cards can also be connected to network cards of other instances of QEMU or local TAP interfaces.

It also has some features that are not present in many emulators. QEMU integrates several services to allow the host and guest systems to communicate, for example, a SMB server and network port redirection (to allow incoming connections to the virtual machine). It can also boot Linux kernels without having to prepare a bootable image with a bootloader.

QEMU does not depend on the presence of graphical output methods on the host system. Instead, it can allow one to access the screen of the guest OS via VNC. It can also use an emulated serial line, without any screen, with applicable operating systems.

Simulating multiple CPUs that can be used like a real SMP system is possible.

Unlike some other emulators, QEMU does not require administrative rights to run, except if additional kernel modules for improving speed are used (like KQEMU).

Tiny Code Generator

The Tiny Code Generator (TCG) aims to remove the shortcoming of relying on a particular version of GCC or any compiler, instead incorporating the compiler (code generator) into other tasks performed by QEMU in run-time. The whole translation task thus consists of two parts: blocks of target code (TBs) being rewritten in TCG ops - a kind of machine-independent intermediate notation, and subsequently this notation being compiled for the host's architecture by TCG. Optional optimisation passes are performed between them.

TCG requires that there be dedicated code written to support every architecture it is being run on. It also requires that the target instruction translation be rewritten to take advantage of TCG ops, instead of the previously used dyngen ops.

Starting with QEMU Version 0.10.0, TCG ships with the QEMU stable release.[4]

Accelerator

KQEMU was a Linux kernel module, also written by Fabrice Bellard, which notably sped up emulation of x86 or x86-64 guests on platforms with the same CPU architecture. This was accomplished by running user mode code (and optionally some kernel code) directly on the host computer's CPU, and by using processor and peripheral emulation only for kernel mode and real mode code.

Unlike KVM, for example, KQEMU could execute code from many guest OSes even if the host CPU did not support hardware virtualization.

KQEMU was initially a closed-source product available free of charge, but as of version 1.3.0pre10,[5] it was relicensed under the GNU General Public License.

QEMU versions starting with 0.12.0 (as of August 2009) support large memory which makes them incompatible with KQEMU.[6] Newer releases of QEMU have completely removed support for KQEMU.

QVM86 was a drop-in replacement for the then closed-source KQEMU, licensed under GNU GPLv2 license. The developers of QVM86 ceased development in January, 2007.

Hardware-assisted emulation

The MIPS-compatible Loongson-3 processor adds 200 new instructions to help QEMU translate x86 instructions; those new instructions lower the overhead of executing x86/CISC-style instructions in the MIPS pipeline. With additional improvements in QEMU by the Chinese Academy of Sciences, Loongson-3 achieves an average of 70% the performance of executing native binaries while running x86 binaries from nine benchmarks.[7]

Parallel emulation

Virtualization solutions that use QEMU are able to execute multiple virtual CPUs in parallel. QEMU is also able to run multiple threads in user-mode emulation mode.

For full system emulation, QEMU uses a single thread to emulate all the virtual CPUs and hardware. COREMU[8] is a patch to QEMU to break this limitation. Each core uses a separate instance of QEMU binary translation engine, with a thin library layer to handle the inter-core and device communication and synchronization.

Integration in other virtualization solutions

VirtualBox

In January 2007, VirtualBox was released. It uses some of QEMU's virtual hardware devices and has a built-in dynamic recompiler that is based on QEMU. As with KQEMU, it runs nearly all guest code natively on the host via the VMM (Virtual Machine Manager), and uses the recompiler only for special situations as a fallback mechanism (this holds true for guest code that executes in real mode and some other rare scenarios at runtime).[9] In addition, VirtualBox goes through a lot of code analysis and patching via a built-in disassembler to reduce usage of the recompiler to a minimum. VirtualBox is open-source software under the GPL, except for a number of enterprise features, and standard user features like USB 2.0.

Xen-HVM

The Xen virtual machine monitor can run in HVM (hardware virtual machine) mode, using Intel VT-x or AMD-V hardware x86 virtualization extensions. This means that instead of paravirtualized devices, a real set of virtual hardware is exposed to the domU to use real device drivers to talk to.

QEMU includes several components: CPU emulators, emulated devices, generic devices, machine descriptions, user interface, and a debugger. The emulated devices and generic devices in QEMU make up its device models for I/O virtualization.[10] They comprise a PIIX3 IDE (with some rudimentary PIIX4 capabilities), Cirrus Logic or plain VGA emulated video, RTL8139 or E1000 network emulation, and ACPI support.[11] APIC support is provided by Xen.

Xen-HVM has device emulation based on the QEMU project to provide I/O virtualization to the VMs. Hardware is emulated via a QEMU "device model" daemon running as a backend in dom0. Unlike other QEMU running modes (dynamic translation or KVM), virtual CPUs are completely managed to the hypervisor, which takes care of stopping them while QEMU is emulating memory-mapped I/O accesses.

KVM

KVM (Kernel Virtual Machine) is a Linux kernel module that allows a user space program access to the hardware virtualization features of various processors, with which QEMU is able to offer virtualization for x86, PowerPC, and S/390 guests. When the target architecture is the same as the host architecture, QEMU can make use of KVM particular features, such as acceleration.

Win4Lin Pro Desktop

In early 2005, Win4Lin introduced Win4Lin Pro Desktop, based on a 'tuned' version of QEMU and KQEMU and it hosts NT-versions of Windows. In June 2006,[12] Win4Lin released Win4Lin Virtual Desktop Server based on the same code base. Win4Lin Virtual Desktop Server serves Microsoft Windows sessions to thin clients from a Linux server.

In September 2006, Win4Lin announced a change of the company name to Virtual Bridges with the release of Win4BSD Pro Desktop, a port of the product to FreeBSD and PC-BSD. Solaris support followed in May 2007 with the release of Win4Solaris Pro Desktop and Win4Solaris Virtual Desktop Server.[13]

SerialICE

SerialICE is a QEMU-based firmware debugging tool running system firmware inside of QEMU while accessing real hardware through a serial connection to a host system. This can be used as a cheap replacement for hardware ICEs.[14]

Shortcomings

Emulated hardware platforms

x86

Besides the CPU, the following devices are emulated:

The BIOS implementation used by QEMU starting from version 0.12 is SeaBIOS. The VGA BIOS implementation comes from Plex86/Bochs.

PowerPC

On the PowerPC target, Open Hack'Ware, an Open-Firmware-compatible BIOS, is used.

PowerMac

QEMU emulates the following PowerMac peripherals:

PREP

QEMU emulates the following PREP peripherals:

ARM

QEMU emulates the ARMv5TEJ instruction set and all the derivative processors families like ARM7, ARM9E, ARM10E and XScale. It emulates full systems like Integrator/CP board, Versatile baseboard, RealView Emulation baseboard, XScale-based PDAs, Palm Tungsten|E PDA, Nokia N800 and Nokia N810 internet tablets etc. QEMU also powers the Android emulator which is part of the Android SDK (most current Android implementations are ARM based). Under development is iEmu, emulator of Apple's iPhone. Starting from version 2.0.0 of their BADA SDK, Samsung has also chosen QEMU to help development on emulated 'Wave' devices.

SPARC

Sun SPARC-Architecture = (Scalable Processor ARChitecture)

When the BIOS in the JavaStation (sun4m-Architecture) became Version 0.8.1 Proll,[16] a PROM replacement used in Version 0.8.2, was replaced with OpenBIOS.

Sparc32

QEMU emulates the following sun4m/sun4c/sun4d peripherals:

Sparc64

Emulating Sun4u (UltraSPARC PC-like machine), Sun4v (T1 PC-like machine), or generic Niagara (T1) machine with the following peripherals:

MicroBlaze

Supported peripherals:

LatticeMico32

Supported peripherals:

From the Milkymist SoC

CRIS

External patches

External trees exist supporting the following targets:

See also

References

External links