QEMU 2 as a versatile virtualization platform
Open Emu

The new version of QEMU is a free virtualization solution that offers excellent stability and flexibility. We show how to deploy QEMU 2 in a Live environment.
Many virtualization solutions exist today, but only a few can look back on a long tradition and many years of development work. After more than 10 years of development, the bell finally rings for round two of QEMU, which offers many special features for improved use and handling. This article looks at how to deploy QEMU 2 in a Live environment.
QEMU (Quick EMUlator) is a free emulator and virtualization solution that allows users to run a variety of operating systems in a virtual environment, much like many other virtualization systems. QEMU 2, which was released in April, can lay claim to several special features that you will not find in its competitors.
QEMU supports many options for launching the guest system, including multiprocessor emulation on single-processor systems. The open source software can also emulate other processor architectures such as PowerPC or ARM.
Because QEMU communicates directly with the kernel, the guest system runs at virtually the same speed as the host system (Figure 1). This good performance is achieved in combination with KVM, which makes it possible to run the guest at almost native speed. You only need to make sure that the processor you use supports hardware virtualization. However, this approach only works if the host and the guest share the same computer architecture. Another special feature is that QEMU does not need guest extensions for the guest, in contrast to VirtualBox or VMware. Additionally, the simulator integrates up to four hard disks.
Versatility
QEMU can be viewed as a technology pioneer in various areas. The developers started to leverage the benefits of KVM back in version 0.12, which helps achieve considerable performance boosts on Linux systems.
Like its competitors – whether free or commercial – QEMU runs on all popular operating systems and processor architectures. If you use QEMU without an accelerator, you do not even need administrative privileges. You can thus store a virtual machine including QEMU on a medium and run it on another computer.
The free virtualization software supports snapshots; thus, it can create multiple copies of the states of your virtual machines and revert system changes if needed. QEMU has other special features to offer: For example, the software supports live migration, system debugging, and booting from older disk formats. You can even emulate hardware errors.
QEMU has a flexible tool in the form of qemu-img
for creating, converting, and encrypting image files (i.e., virtual hard disks in various formats). QEMU lets you boot from image files from other virtualization tools, and it provides support in the opposite direction, too: You can create virtual machines for KVM, Xen, and other hypervisor systems. It is even possible to export image files across the network. To do so, use the qemu-ndb
tool, which in turn relies on the Network Block Device (NBD) protocol.
QEMU also supports libvirt, which is a cross-hypervisor abstraction layer for managing virtual machines. Building on this layer, management tools such as Virtual Machine Manager or virsh
can manage a variety of virtualization solutions. Thus, there's nothing to prevent you from running QEMU parallel to existing virtualization solutions.
Getting Started with QEMU
In principle, you can run QEMU 2 in Windows and UNIX-based environments, but to leverage its full potential, you will probably want to opt for a Linux system. Debian or Ubuntu are good choices.
Before you start installing QEMU 2, you must explicitly enable support for hardware virtualization in your computer's BIOS. The settings differ greatly from BIOS to BIOS and between motherboard manufacturers. If you have a gigabyte motherboard, you will find the options for enabling the CPU's virtualization feature in the Award BIOS below Advanced CPU Features. For other motherboard manufacturers, refer to your motherboard documentation. You can check the CPU to see whether your CPU supports the required virtualization technologies using the following command:
grep "vmx" /proc/cpuinfo
Once you have sorted out the question of virtualization support, you can proceed with the installation. More recent Linux distributions will group QEMU and KVM in the qemu-kvm package. However, because this package only supports x86 guest systems, it is a good idea to install the qemu-kvm-extras package, which provides emulators for other architectures.
The easiest way to install QEMU 2 is to use your distribution's package manager. Thus, if you work with Debian and Ubuntu, you would choose Synaptic. The important thing here is to enable all the program sources in the System | Administration | Software sources menu. If you prefer working at the command line, run the following command:
sudo apt-get install kvm qemu-kvm qemu-kvm-extras
On Fedora, Red Hat Enterprise Linux, and CentOS, you would use yum
for the install:
yum install qemu-kvm qemu-kvm-extras
Installation is also simple on openSUSE, where you turn to YaST and look for the qemu-kvm and qemu-kvm-extras packages.
If you are installing QEMU 2 with the help of the package manager, it makes sense to install a graphical interface for the virtualization environment at the same time (Figures 2 and 3). Doing so provides the convenience that may be familiar from using virtualization programs such as VirtualBox on Windows. This gives you a complete virtualization environment, and you can fire up the first virtual machine.
QEMU Fast Track
Once the basic QEMU 2 system is installed, you can install the first virtual machine, which typically involves three steps. In the first step, you generate a virtual hard disk – or an image file to be more precise. The second step is launching QEMU or KVM along with the virtual machine and executing the installation medium. This configures a virtual machine with the intended start options. The third step is installing the operating system. You only need to make sure that the emulated hardware is supported. There is no need to install special drivers on the guest system.
The virtualization environment uses identical start options on all operating systems. You can access and execute the most important options at the command line. The benefit of this is that any error messages will be output directly in the terminal.
To install a guest operating system, you first create the virtual hard disk. To do so, run the qemu-img
tool that comes with the QEMU package using the create
parameter. The -f
option lets you determine the format of the image file:
qemu-img create -f qcow2 example-image.img 5G
Next, you need a bootable image or medium for the operating system that you want to install as the guest system. You can call QEMU 2 with one of the following commands:
qemu-system-x86_64 qemu-system-i386
On some Linux distributions, you can also use the kvm
command. If you are booting a virtual machine from a CD, remember to add the -cdrom
option after the image file name. Pass in the name of the virtual hard disk you created with the -hda
option. Now the virtual computer just needs to know that you want it to boot from the virtual CD, and the -boot d
option clarifies this:
qemu-system-x86_64 -m 512 -hda example-image.img -cdrom example-OS.iso -boot d
Occasionally you might see an error message at boot time stating that the bios.bin
file is missing. In this case, you need to add the -L
start option along with the path to this file. If the bios.bin
file resides in the current directory, you need to specify this with a dot:
qemu-system-i386 -m 512 -hda example-image.img -cdrom example-OS.iso -boot c -L .
This command launches the virtual PC in a separate window. When you click on the window, the mouse pointer is captured and you can use the mouse within the guest system. The Ctrl+Alt keyboard combination releases the mouse pointer again.
After completing the installation of the operating system, you need to restart the virtual machine; then, to boot the newly installed system from the virtual hard disk, use the -boot c
option:
qemu-system-i386 -m 512 -hda example-image.img -cdrom example-OS.iso -boot c
You can also boot off the network, with:
qemu-system-i386 -m 512 example-OS.img -net user -net nic,model=pcnet
Here, QEMU 2 uses the integrated DHCP server to define a guest system's network settings.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.
News
-
The GNU Project Celebrates Its 40th Birthday
September 27 marks the 40th anniversary of the GNU Project, and it was celebrated with a hacker meeting in Biel/Bienne, Switzerland.
-
Linux Kernel Reducing Long-Term Support
LTS support for the Linux kernel is about to undergo some serious changes that will have a considerable impact on the future.
-
Fedora 39 Beta Now Available for Testing
For fans and users of Fedora Linux, the first beta of release 39 is now available, which is a minor upgrade but does include GNOME 45.
-
Fedora Linux 40 to Drop X11 for KDE Plasma
When Fedora 40 arrives in 2024, there will be a few big changes coming, especially for the KDE Plasma option.
-
Real-Time Ubuntu Available in AWS Marketplace
Anyone looking for a Linux distribution for real-time processing could do a whole lot worse than Real-Time Ubuntu.
-
KSMBD Finally Reaches a Stable State
For those who've been looking forward to the first release of KSMBD, after two years it's no longer considered experimental.
-
Nitrux 3.0.0 Has Been Released
The latest version of Nitrux brings plenty of innovation and fresh apps to the table.
-
Linux From Scratch 12.0 Now Available
If you're looking to roll your own Linux distribution, the latest version of Linux From Scratch is now available with plenty of updates.
-
Linux Kernel 6.5 Has Been Released
The newest Linux kernel, version 6.5, now includes initial support for two very exciting features.
-
UbuntuDDE 23.04 Now Available
A new version of the UbuntuDDE remix has finally arrived with all the updates from the Deepin desktop and everything that comes with the Ubuntu 23.04 base.