Build and Install the Latest QEMU Machine Emulator from Source


QEMU is a generic and open source machine emulator and virtualizer. This installation will work on Fedora (I’ve tested on Fedora 8, 11, and 12) and Ubuntu (9.10) but since you’re installing from source, it should work on just about any flavour of Linux given you’re running on a supported architecture, which as of the time of this writing is 32 or 64 bit x86 or PowerPC. Testing is in progress for hosting QEMU on ARM, MIPS, PowerPC64, and SPARC. And the best news is, you can emulate ALL of these architectures to a guest system. For a complete list of supported platforms, check http://www.claunia.com/qemu/.

Download the latest source tarball from the QEMU homepage:

http://www.qemu.org/download.html

When used as a machine emulator, QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a different machine (e.g. your own PC). By using dynamic translation, it achieves very good performances.

When used as a virtualizer, QEMU achieves near native performances by executing the guest code directly on the host CPU. A host driver called the QEMU accelerator (also known as KQEMU) is needed in this case. The virtualizer mode requires that both the host and guest machine use x86 compatible processors.

qemu-installing-windows

===Build the QEMU emulator:===
$ tar xzvf qemu-*.tar.gz
$ cd qemu*
$ ./configure
$ make
$ sudo make install

I used sudo during the install because I put the files in my home directory and ran configure/make as a normal user, but I needed root privileges to let the install script put the binaries into /usr/local/bin/. It’s safer to build as a normal user. You don’t want some Makefile changing system files, breaking your system, or worse.

===Build the QEMU accelerator:===
$ tar xzvf kqemu-*.tar.gz
$ cd kqemu*
$ ./configure
$ make
$ sudo make install

===Load the kernel module:===
$ sudo /sbin/modprobe kqemu

At this point we’re done. If you have any pre-built virtual hard drives, you can start them up now. If you want to install something from scratch, continue on from here…

===Create a virtual storage file===
You can make a 40GB hard drive for the virtual machine, but using qcow, it will start as only 16k on disk and expand as it’s used. This will save a lot of space, especially if you run more than one virtual machine. From inside your virtual guest, you will see the device as the full 40GB right from the start.

$ qemu-img create -f qcow ntfs.img 40G
Formatting ‘ntfs.img’, fmt=qcow size=42949672960 encryption=off

===Install Windows===
Insert a Windows installation disc in your DVD drive or use an .ISO image file. This could be Ubuntu, Fedora, Gentoo, cflinux, Knoppix, Windows, or whatever else you can think of. Here I give the machine 1GB of memory and boot from cdrom.

$ qemu -localtime -cdrom /dev/cdrom -m 1024 -boot d ntfs.img

This will open a new window that will look like the bios booting up, and then straight into the Windows installation screen, probably a blue screen asking you to setup your hard drive for a new installation or repair an existing windows. Use it long enough and i’m sure you’ll find the next kind of blue screen of death, or bsod. But that’s just because it’s Windows, and has nothing to do with Emulation or Virtualization at all.

If you get the following message on first boot, restart, hit F8, and go into safe mode. Let it load all the way and then do a clean shutdown. It shouldn’t complain on next boot.

A problem is preventing Windows from accurately checking the
license for this computer. Error code: 0x800703e6.

====Share files between the Windows guest and Linux host====
$ qemu -smb $HOME/qemu -m 384 -localtime ntfs.img

Open a command prompt in the Windows guest and run the following:
net use e: \\10.0.2.2\qemu

If you didn’t do anything special to set up networking, the host will be 10.0.2.2 because you get a hard coded virtual network by default that you can use to access services between the host/guest (web server, file server, etc.)



Comments are closed.