Emulation with QEMU

Home / Emulation with QEMU

Emulation with QEMU

December 5, 2015 | Article | 1 Comment

On previous article, we have discuss about how to install QEMU-KVM on Slackware64 and Windows. In this article we will discuss about Virtualization and Emulation using QEMU.

QEMU – Overview

QEMU is an emulator and vitualization tool like VMware, KVM, VirtualBox, and Xen did. It emulates hardware, but with more options available. QEMU is available to emulates some hardware architectures, including embedded system. Processor architecture supported by QEMU are: x86, ARM, MIPS, etc.

QEMU is cross platform, available for many Operating System such including Linux, Microsoft Windows, and any Unix-like as its host operating system.

How it work

QEMU is like any virtualization tools, dividing resource for native OS (the host) and virtual machine (guest). It support virtualization with Xen Hypervisor or Linux KVM modules. With KVM, QEMU can emulate x86, server and embedded PowerPC, and also S390.

As result of resource division, there will be a decreasing in performance both on host and guest system. However, QEMU use dynamic translation to translate machine code of guest to host which makes the performance good enough.

Operating Mode

QEMU has two operating mode, which are:

  1. User Mode Emulation – QEMU can emulate own Linux process which is compiled to a CPU on different CPU.
  2. Full System Emulation – QEMU emulate whole system, including every resource (suh as processor and peripheral). This mode is useful to do some debugging and code testing on virtual machine. Using QEMU we can run some virtual machines simultaneously on a host (of course we should measure the resource needed).

Installation

The installation can be done easily. You can install QEMU by following this article for Linux and this article for Windows.

Running Kernel Image

You can read this article to run a simple Debian for ARM distribution.

Playing with Arguments

Following are arguments that can be used for running a system.

Function Command Notes
 Specifying amount of RAM  -m x  X is the amount of RAM in MB
 Use initial ramdisk  -initrd PATHANDFILENAME
 Add additional disks  -hdb DISK2 -hdc DISK3 -hdd DISK4
 Add cdrom drive  -cdrom FILE  FILE can be ISO or /dev/cdrom on UNIX
 Disable graphic  -nographic  Useful for emulate a headless raspi or to route the output directly to terminal
 Make QEMU exits when the system reboot  -no-reboot
 Pass argument to kernel  -append “KERNEL OPTIONS”  the kernel OPTIONS will be discussed on next section.

Kernel Options

Following are arguments that can be passed to kernel (the one QEMU boot).

Function Command Notes
 Specify what partition of disk will be the root partition  root=DEVICE
 Specify what file to run after kernel is loaded  init=FILE
 Prevent QEMU from simply freeze when the kernel is panic  panic=x  x is the number of seconds before rebooting. Usefule with the -no-reboot option
 Specify default console device for the output.  console=DEVICE

Disk Operation

In this section we will discuss about creating a disk image for QEMU. It is recommended to use Linux. The general syntax for creating a disk is:

qemu-img create <FILENAME> <SIZE>

Where <FILENAME> is filename and path if you don’t want to create the image on current directory. The size is written in numerical value followed by size unit in:

  • k or K for Kilobyte (1024 byte)
  • m or M for Megabyte (1025 kb)
  • g or G for Gygabyte (1024m mb)

The created file contain 0 (zero) and mean nothing to system.

To format a disk, we can use UNIX & Linux utility:

  • EXT2 => mkfs.ext2 <FILENAME>
  • EXT3 => mkfs.ext3 <FILENAME>
  • etc

We can also mounting <FILENAME> to modify it.

, , ,

About Author

about author

xathrya

A man who is obsessed to low level technology.

1 Comment
  1. Emulating Raspberry Pi using QEMU - Xathrya.ID

    […] are in situation where we can’t afford the board? Emulation sure is the way to experiment and QEMU open the […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial