QEMU: a Multihost, Multitarget Emulator

QEMU comes to the rescue for those times when VMware is overkill.

Looking back, a better size would have been 4GB, because that would have made it easier to create DVD backups.

Now that I had a virtual hard drive, I put my Windows XP Pro installation CD into my CD-ROM drive and launched QEMU with the appropriate arguments:


qemu -boot d -hda path/to/winxp.img -cdrom /dev/cdrom -m 256 -localtime

The -m 256 option set the memory allocated to the VM to 256MB—the default is 128MB, which is a bit small for Windows XP Pro. The -localtime option set the virtual BIOS clock to the local time on the host machine—the default is to set the BIOS clock to Universal Coordinated Time.

Figure 2. Booting Windows for the First Time

I found that installing Windows onto a virtual machine was very similar to installing it on a “real” computer. The installer comes up and has you choose where to install Windows. It asks you if you want to format your hard drive, prompts you to enter in your license key and so on. Once the base install was done, I shut down the VM, replaced my Windows XP Pro installation CD with my Microsoft Outlook installation CD and launched QEMU like so:


qemu -boot c -hda path/to/winxp.img -cdrom /dev/cdrom -m 256 -localtime

The only difference was to boot from winxp.img instead of from /dev/cdrom. The Outlook installation went like a typical Outlook installation—no real surprises there. When the Outlook installation was completed, I had a functioning Windows machine to call on whenever I needed it.

Figure 3. Windows XP Pro Running in QEMU

Now that I had my base operating system and needed application installed, I shut down the machine and created a GNOME launcher, so I could fire up my virtual Windows machine without typing it into my terminal every time. As you can see from Figure 4, I basically removed the CD-ROM info from the command, because I don't need a CD-ROM to be present during normal operation. Refer to the documentation for your distribution on how to create a custom application launcher.

Figure 4. A Simple GNOME Launcher for QEMU

Squeezing More Performance out of QEMU

There are a few ways to squeeze extra performance out of QEMU:

  1. More RAM: the first thing I did was add more RAM. I did not want QEMU to have any reason to access my swap partition. Swap partitions are very useful, but too slow for resource-intensive tasks such as emulation. With more RAM, you get not only better performance from your VM, you also can run multiple VMs at the same time (see Figure 5 for an example of this).

  2. KQEMU: the second thing I did to get better performance was to compile in the KQEMU accelerator module.

  3. Set up a RAM disk: even with extra memory, there are times when QEMU needs to cache things to disk. To speed up this process, I set up a RAM disk. A RAM disk is a virtual disk drive created from free RAM. To create it, I entered the following into my /etc/fstab and then rebooted my machine:

    
    tmpfs        /dev/shm        tmpfs    defaults    0    0
    
    

Figure 5. QEMU Running Three Virtual Machines Simultaneously

Getting Files in to and out of QEMU

A dilemma I ran into after I started using QEMU was how to get files out of my QEMU VM for backup purposes. The first method I tried was to install an SSH secure copy (scp) client for Windows and then use it to transfer files to myself. This works, but it was not as simple as I wanted the process to be.

The second method I tried worked much better. When starting QEMU, there is an option to specify a shared directory. QEMU makes it available to the VM through Samba, so you need to have Samba installed for this to work. The option is -smb dir—where dir is the directory on my host machine for which I want my Windows XP VM to have access. I then added the following line to C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS on my Windows XP VM:


10.0.2.4 smbserver

Accessing my shared folder from within my VM was then as easy as navigating to \\smbserver\qemu.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

qvm86 is officially (?) obsolete

Geraldo's picture

From qvm86's project site on Savannah a post from the admin:

-- BEING POST --
qvm86 is obsolete
posted by pbrook, Sunday 01/21/07 at 16:16 UTC - 4 replies

InnoTek have released their VirtualBox code under the GPL.
As far as I'm concerned this obsoletes qvm86, and I see no point continuing development. I recommend anyone interested in qvm86 use VirtualBox ...
-- END POST --

QEMU is alive

Gabriel Menini's picture

Actually, QEMU and VirtualBox are different products.

VirtualBox has a very nice GUI and is available both for Linux and Windows.

On the other hande, I find using QEMU very simple ;-)

BTW, great magazine article.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState