QEMU: a Multihost, Multitarget Emulator
To install QEMU, download the source package from the main QEMU Web site (see Resources) and the binary kqemu package. There is also a binary QEMU package available. If you download and install the binary, you will not be able to use KQEMU, because it needs to be compiled into QEMU to work. KQEMU, unlike QEMU, is available only as a binary package. It is not open source. See the KQEMU sidebar for more information. At the time of this writing, QEMU is at version 0.8.0, and KQEMU is at version 0.7.2. Because they are under active development, there may be updated versions available by the time you read this.
Once I had downloaded the two packages, I first untarred QEMU with:
tar -zxvf qemu-0.8.0.tar.gz
Next, I changed directories into the qemu-0.8.0 directory I had just created and did:
tar -zxvf ../path/to/kqemu-0.7.2.tar.gz
This created a kqemu directory inside of my qemu-0.8.0 directory.
When I compile applications from source, a ./configure, make, make install at this point is usually all that I need to do to get a piece of software installed. QEMU needed a bit more hand holding.
In order to have QEMU compile successfully on my machine, I had to make a few changes to the configure script. The changes themselves were quite simple. First, QEMU does not get along with 4.x versions of gcc, so I had to change the cc= and host_cc= lines to use gcc-3.4 specifically. Then, I had to change kqemu="no" to kqemu="yes". Finally, it was necessary to enter the path to my kernel source tree in kernel_path="". One note: QEMU uses SDL for output, so although I did not need to install anything extra for my particular setup, others may have to install some SDL libraries before the configure script will be happy.
Once I was able to run ./configure without it complaining, I ran make and then make install to install QEMU to my /usr/local/ directory. To install the KQEMU accelerator kernel module, I typed the following into an open terminal:
Unlike QEMU, which is open source, KQEMU is a closed-source, proprietary product. The reason for this is money. QEMU developer Fabrice Bellard has stated that he would be willing to open-source KQEMU on one condition: if a corporate sponsor picked up the tab for its continued development. Until then, although you can download it without cost, KQEMU will remain a proprietary component in an otherwise open-source product.
There is a project to create an open-source drop-in replacement to KQEMU called qvm86 (see Resources). I have not used it, but I have read statements that say it works as well as or better than KQEMU.
Once I had installed QEMU, I wanted to see it in action. The easiest way to try it out was to boot a live CD ISO image like KNOPPIX, Ubuntu, SimplyMepis, DSL, Puppy or one of the scores of others. To boot QEMU off a bootable CD image, I simply entered the following at the command line:
qemu -boot d -cdrom path/to/distro.iso
The -boot d parameter tells QEMU to boot from the CD drive, and -cdrom path/to/distro.iso tells QEMU where the CD-ROM “drive” is, which in this example, is simply an ISO image. I also could have pointed QEMU at my actual CD-ROM drive—/dev/cdrom—and when I installed Windows, that is what I did.
Before I could install an operating system, I first needed to prepare a virtual hard disk in which to install. QEMU understands various disk image formats, including VMware's vmdk, which would have come in handy if I had some of them lying around. As it turned out, the default, “raw” format worked well. A raw format disk image acts like an unformatted hard drive, which was perfect for my needs.
I used the following command to create an image named winxp.img, 5GB in size, which I figured was big enough to install Windows XP and Outlook and give me plenty of e-mail storage:
qemu-img create winxp.img 5120M
- Brent Laster's Professional Git (Wrox)
- Smoothwall Express
- Returning Values from Bash Functions
- Own Your DNS Data
- Bash Shell Script: Building a Better March Madness Bracket
- Machine Learning Everywhere
- Simple Server Hardening
- From vs. to + for Microsoft and Linux
- The Weather Outside Is Frightful (Or Is It?)
- Ensono M.O.