Taking QEMU for a Spin

| |

QEMU in actionQEMU in actionHave you tried QEMU? I must admit that I hadn't really tried it until recently... although I have used VMware and Parallels. Supposedly Xen and the new KVM both draw from QEMU code. What is QEMU? Obligatory quote from the QEMU wikipedia entry:

QEMU is free software written by Fabrice Bellard that implements a fast processor emulator, allowing a user to simulate a complete computer system within another one. It is similar to projects such as Bochs, VMware Workstation and PearPC, but has several features these lack, including increased speed on x86, and support for multiple architectures in-progress. By using dynamic translation it achieves a reasonable speed while being easy to port on new host CPUs.

I'm not sure why that says that QEMU is faster than VMware, because it isn't... but QEMU can emulate several different CPU families other than just x86. Read on if you want to hear about my experience installing Windows XP SP2 from an .iso file.

Installing QEMU

I run Fedora Core 5 on my work machine and as luck would have it, QEMU is available in the Fedora Core 5 Extras repository. A quick yum install qemu and it was installed.

What OS to install

I decided to install Microsoft Windows XP Service Pack 2. Why? Because I'm already running Linux and I find it boring to install Linux within Linux unless I'm trying out a new/different distro. I also already had an .iso file of the XP install media. Don't freak out, it's ok... we are a member of the MSDNAA/ELMS system and can generate license codes at will... so I'm NOT pirating Windows here.

Creating a virtual disk image

Before I can install an OS, I need a place to install it. QEMU uses image files and creating a filesystem is as easy as:

qemu-img create -f qcow winxp.img 5G

As you can probably figure out, that will create an image with a max capacity of 5GB. qcow is a compressed image format native to QEMU. The command above finished almost immediately and produced file named winxp.img 21K in size. You see, qcow does NOT have to reserve all of the space up front... no writing 5GB worth of zeros to the image file... it will GROW as space is needed.

Cool. That was pretty easy.

Installing Windows

Install beginsInstall beginsOk, now I need to start the virtual machine and tell it to boot from an .iso CD image... and see my image file as a hard drive. Turns out, that is as easy as:

qemu -cdrom winxp_pro_with_sp2.iso -hda winxp.img -m 256 -boot d

That is actually readable, eh? The -m 256 flag specifies the amount of RAM the virtual machine is to have. After issuing that command a window popped up and the BIOS screen zipped by. I would have liked to have gotten a screen capture of the BIOS screen but it went by so fast, I didn't have time. Hey, it even booted from the CD image as desired. Windows saw a 5GB hard drive... and I formatted it as NTFS for the install and that was pretty quick. The text portion of the install progressed as expected... and then the machine rebooted into the GUI phase of the install.

License keyLicense keyThe Windows GUI phase continued as one would expect. I mean, how many times have I gone through this? I manage a lab full of computers at work and they are dual-boot... so I've done my share of Windows installs. Luckily for larger deployments these days I use products like Ghost and sys-prep to keep me from going crazy... but I've still done a lot of Windows installs. I mean, how do you fix a nasty problem in Windows anyway? Why everyone knows you reinstall. :)

Booting Windows for the First Time

First bootFirst bootThe install took a while but once it was done, Windows restarted, and it went through configuring itself. It asked me to configure networking, which I did... and I was able to join our Windows Active Directory Domain just fine.

Now I ask you... What is the first thing you do after installing Windows? You guessed it... Windows Updates! There quite a few updates... and it took a while.

Login screenLogin screenOddly enough, by default QEMU uses private IP addresses. This virtual Windows machine had a 10.0.x.x address and had also set private addresses for the gateway and DNS. I'm not sure how it works mainly because I haven't taken the time to read the fine QEMU documentation... but strangely enough, it worked just fine on the LAN at work. I mean, how else could I have joined the AD Domain and done Windows updates?

Speed and performance

QEMU works well. It is fairly fast... which is pretty impressive given the fact that it can emulate several different processor families... and that it will run on several platforms. How fast is it? Well, it isn't as fast as VMware but it seems serviceable. While I haven't run any benchmarks... I'd have to guess that QEMU is about one half to three quarters as fast as VMware... which is actually quite good... since VMware is pretty darn fast. You have to also take into consideration that QEMU is running as a regular user process, doesn't use a kernel module... and since it isn't using a kernel module, it doesn't have to be rebuilt every time one changes kernels.

Conclusion

Doing UpdatesDoing UpdatesSeeing as how easy QEMU was, given all of the ingredients, to install, to create a disk image, and to install an OS, you don't have to rely on my experience alone. Install it for yourself... and let us know how it went.

For advanced users who are willing to read the documentation, there are ways to improve QEMU's preformance... but I wasn't interested in compiling a custom kernel module as it is quite usable as is.

I did have a few points during the install where Windows was supposed to reboot... and it just sat there so I hit the close [X] in the top right of the QEMU window and then started it up again. From that I conclude that, at least on my hardware, there may be times when it can't sense a software restart. Other times Windows wanted to reboot, like after updates, it worked just fine. That really is just a minor bug but something you should be aware of. I only ran into it during the install... so maybe I've seen the last of it?!?

Of course after the updates were done... the next thing to do is to install all of the wonderful free programs we are used to using... like Firefox, GIMP, OpenOffice.org, Inkscape, etc.


Comment viewing options

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

qcow1 qcow2 raw

talking about speed. What ya think which image format is the fastest and best in performance. Raw, qcow1 or qcow2.


Scott Dowdle's picture

Choosing a disk format

Wow, that was a long time ago and I have since switched to KVM... which does still use a lot from QEMU. I just go by whatever format virt-manager makes when I select to allocate all of the space now... so I don't have any advice for you. Sorry.

Given the speed of QEMU by itself, I'm not sure if one disk type is going to have any significant performance advantage over another... and that you'd get a much better performance enhancement switching to KVM or VirtualBox.


Thomas's picture

re: Qemu

Hello Scott,

Your blog on "Turning LiveCDs into LiveUSBs" got me thinking about putting Slax on a USB. Slax is very small in the first place, only a 190MB ISO image. It's also the only LiveCD/DVD or USB distro [THAT I KNOW OF] that you can save files on the boot media. Slax was intended to be a pocket OS, or a take it with you sort of distro.

I mention this because in my quest to install Slax to a USB I found, www.pendrivelinux.com. I installed QemuSlax on USB and am quite impressed. In the event of a system failure, USB boot of any distro could be very useful.

Unfortunately, tonight the SLAX website is down. I'm sure it'll be back soon.

Thomas

Scott Dowdle's picture

Article on QEMU networking options

I was cruising the Fedora People site the other day and ran across an entry regarding QEMU Networking that I thought would come in handy for anyone wanting to do fancy networking stuff with QEMU.

Regarding QEMU's speed... after using it a while, I'll have to say that it wasn't as fast as I thought it was... when I first wrote up the article. I'd have to say that it is about 1/4 to 1/2 the speed of VMware.


QEMU is too slow

QEMU speed has been the biggest turn off for me. It crawls compared to other things out there. I use Innotek VjrtualBox OSE and it works great. It does not do everything that QEMU does like diffrent processor architectures and it does use a kernel module. However it is fast, I use it for my windows only tools that vendors force upon me. If I were going to ever need to run something on a diffrent architecture at least I would know where to do it now.

If anybody does install the kernel module for QEMU please report if there is any speed increase. I would be interested in knowing.

_
/-\ ndrew


Scott Dowdle's picture

KQEMU

When I wrote the article, KQEMU (the kernel module that accelerates QEMU) was freely available but closed source. Since then it has been released under the GPL.

Yes... Parallels, VMware Server/Player, and VirtualBox are all faster. I haven't used KQEMU but it is my understanding that when you use it, it does speed up QEMU a LOT making it more comparable to the other guys.


Comment viewing options

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