What is QEMU in Linux?

QEMU is free and open source (FOSS) hardware virtualization toll developed by Fabrice Bellard distributed under GPL license. It supports a wide range of operating systems including Windows and MacOS. Bochs, PearPC, etc. are similar, but do not have many of its features, such as high-speed and cross-platform features.  It is like VirtualBox and VMware virtualization software but natively it is command based tool unlike the two mentioned. To get the near-native speed of hardware in a virtualization environment one can use it with the KVM with the help of hardware extensions such as Intel VT-x.

qemu of 0.9.1 and earlier can use the kqemu accelerator. In the version after qemu1.0, kqemu cannot be used , mainly using the qemu- kvm acceleration module, and the acceleration effect and stability are significantly better than kqemu.

Read more… How to install and use Qemu command line to create virtual machines.

Mode of operation

QEMU has two main modes of operation:

User mode simulation mode.  

A Linux program compiled with a central processor. The Wine and Dosemu is its main goal.

System mode simulation mode, which is the system mode.

QEMU can simulate the entire computer system, including the central processing unit and other peripheral devices. It makes it easy to test and debug programs written across platforms. It can also be used to virtualize several different virtual computers on a single host.

The main part of QEMU is released under the LGPL, while its system mode simulation is released under the GPL; and the kqemu accelerator is released under free but closed source conditions. The kqemu allows QEMU to be simulated to near real speed, but it is useless if the virtual operating system is Microsoft Windows 98 or below.

QEMU Software advantages

  • Multiple architectures are supported by default.
  • Can simulate IA-32 ( x86 ) PC, AMD 64 PC, MIPS R4000, Sun SPARC sun3 and PowerPC (PReP and Power Macintosh) architecture
  • Scalable to customize new instruction sets
  • Open source, portable, fast simulation
  • On the x86 architecture that supports hardware virtualization, one can use KVM to accelerate with the kernel ksm large page backup memory, which is much faster than VMware ESX.
  • Increased simulation speed, some programs can even run in real time
  • Programs that can run Linux on other platforms
  • Can store and restore operating status (such as running programs)
  • Virtual network card

QEMU virtualization Software disadvantages

  • Imperfect support for Microsoft Windows and certain host operating systems.
  • Support for less common architectures
  • Unless you use the kqemu or KVM accelerator, its simulation speed is still not as good as other virtual software, such as VMware.
  • Difficult to install and use than other simulation software such as VirtualBox.

Usage

The following instructions can create a 500MB “qcow” format hard disk image.

Qemu-img create -f qcow c.img 500M

The following instructions will cause the virtual machine to run in 128MB of memory, using c.img, which uses the hard disk image created by the above instructions and linux.iso as the CD image.

Note that if you are using a physical optical drive, change the -cdrom linux.iso parameter to -cdrom /dev/cdrom or the CD-ROM you are using.

Qemu -clock dynticks -rtc-td-hack -localtime -hda c.img -cdrom linux.iso -boot d -m 128 -enable-audio -localtime

If you want to use the full-screen driver operating system by default, you can add the “-full-screen” parameter to the above command. If you want to leave the full screen at runtime, use the key combination Ctrl-Alt-F.

Qemu Parameter introduction

-L dir points to the directory where the BIOS and VGA BIOS are located

-hda/-hdb/-hdd/-hdc “filename” Use “filename” as the hard disk 0/1/2/3 image.

-cdrom “filename” Use “filename” as the CD image (the file should be of ISO type).

Users of Windows can use the physical CD by the following instructions:

-cdrom //./x: -> x for disc name/location

For example: -cdrom //./e: -> Use E:\ for the disc

-fda/-fdbfilename” Use “filename” as the disk 0/1 image.

-boot [a|d|c] Use disk <a>, disc <d>, or hard disk <c> to boot.

-m size specifies the size of the memory in megabytes.

-soundhw ? List all available sound cards

-soundhw all Use all sound cards

-usb allows the use of usb devices.

The -usbdevice name adds a usb device “name”.

-net nic Create a new network card.

For more commands see the official Qemu page

Acceleration module

Kqemu

The kqemu acceleration module is a closed source add-on designed by Fabrice Bellard for the Linux kernel to speed up the QEMU subsystem. Simulate x86 operating systems on x86 hardware up to real machine speed.

The QEMU Acceleration Module (kqemu)
The kqemu acceleration module is a closed source add-on designed by Fabrice Bellard for the Linux kernel to speed up the QEMU subsystem. Simulating an x86 operating system on x86 hardware can achieve host speed. As said, QEMU Acceleration Module, kqemu , is an open source commercial product. GPLv2 license has been licensed since version 1.3.0pre10. You may use it for personal use without restriction. However, if you want to distribute the QEMU Acceleration Module using a CD, ISO image or add-on kit, you must contact the author and obtain their consent before proceeding. In the newest versions of Qemu, it dropped the support to KQemu.
QVM86
In addition to the above-mentioned kqemu closed-source QEMU acceleration module, there is also a QEMU acceleration module released under the GPL called QVM86 which is almost obsolete now.
Intel’s Hardware Accelerated Execution Manager (HAXM) is an open-source alternative for above two accelerations modules. Starting with version 2.9.0, the official QEMU includes support for HAXM.

QEMU supports the following disk image formats: 

  • .dmg
  • Bochs – Read-only
  • Linux cloop – Read-only
  • .hdd, .hds – Read-only
  • QEMU- .qcow2, .qed, .qcow, .cow
  •  .vdi, .vhd, Virtual VFAT, .vmdk, .img, and .iso