Taking QEMU for a Spin

  • user warning: Table 'cache' is marked as crashed and should be repaired query: SELECT data, created, headers, expire FROM cache WHERE cid = 'filter:1:5564b39d88dff6326fc88398376eb700' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: UPDATE cache SET data = '<p><span class=\"inline right\"><a href=\"/\" onclick=\"launch_popup(104, 640, 512); return false;\" target=\"_blank\"><img src=\"http://www.montanalinux.org/files/images/fullscreen.img_assist_custom.jpg\" alt=\"QEMU in action\" title=\"QEMU in action\" class=\"image img_assist_custom\" width=\"96\" height=\"77\" /></a><span class=\"caption\" style=\"width: 94px;\">QEMU in action</span></span>Have you tried <a href=\"http://fabrice.bellard.free.fr/qemu/\" target=\"_qemusite\">QEMU</a>? 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 <a href=\"http://en.wikipedia.org/wiki/QEMU\" target=\"_wpart\">wikipedia entry</a>:<br />\n<blockquote><i>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></p></blockquote>\n<p>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.</p>\n<p><b>Installing QEMU</b></p>\n<p>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 <code>yum install qemu</code> and it was installed.</p>\n<p><b>What OS to install</b></p>\n<p>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.</p>\n<p><b>Creating a virtual disk image</b></p>\n<p>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:</p>\n<p><code>qemu-img create -f qcow winxp.img 5G</code></p>\n<p>As you can probably figure out, that will create an image with a max capacity of 5GB. <code>qcow</code> is a compressed image format native to QEMU. The command above finished almost immediately and produced file named <code>winxp.img</code> 21K in size. You see, <code>qcow</code> 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.</p>\n<p>Cool. That was pretty easy.</p>\n<p><b>Installing Windows</b></p>\n<p><span class=\"inline right\"><a href=\"/\" onclick=\"launch_popup(102, 640, 370); return false;\" target=\"_blank\"><img src=\"http://www.montanalinux.org/files/images/qemu1.thumbnail.jpg\" alt=\"Install begins\" title=\"Install begins\" class=\"image thumbnail\" width=\"100\" height=\"58\" /></a><span class=\"caption\" style=\"width: 98px;\">Install begins</span></span>Ok, 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:</p>\n<p><code>qemu -cdrom winxp_pro_with_sp2.iso -hda winxp.img -m 256 -boot d</code></p>\n<p>That is actually readable, eh? The <code>-m 256</code> 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.</p>\n<p><span class=\"inline right\"><a href=\"/\" onclick=\"launch_popup(100, 640, 499); return false;\" target=\"_blank\"><img src=\"http://www.montanalinux.org/files/images/qemu4.thumbnail.jpg\" alt=\"License key\" title=\"License key\" class=\"image thumbnail\" width=\"100\" height=\"78\" /></a><span class=\"caption\" style=\"width: 98px;\">License key</span></span>The 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. :)</p>\n<p><b>Booting Windows for the First Time</b></p>\n<p><span class=\"inline right\"><a href=\"/\" onclick=\"launch_popup(99, 640, 495); return false;\" target=\"_blank\"><img src=\"http://www.montanalinux.org/files/images/qemu6.thumbnail.jpg\" alt=\"First boot\" title=\"First boot\" class=\"image thumbnail\" width=\"100\" height=\"77\" /></a><span class=\"caption\" style=\"width: 98px;\">First boot</span></span>The 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.</p>\n<p>Now I ask you... <b>What is the first thing you do after installing Windows?</b> You guessed it... Windows Updates! There quite a few updates... and it took a while.</p>\n<p><span class=\"inline right\"><a href=\"/\" onclick=\"launch_popup(96, 640, 495); return false;\" target=\"_blank\"><img src=\"http://www.montanalinux.org/files/images/qemu9.thumbnail.jpg\" alt=\"Login screen\" title=\"Login screen\" class=\"image thumbnail\" width=\"100\" height=\"77\" /></a><span class=\"caption\" style=\"width: 98px;\">Login screen</span></span>Oddly 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?</p>\n<p><b>Speed and performance</b></p>\n<p>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.</p>\n<p><b>Conclusion</b></p>\n<p><span class=\"inline right\"><a href=\"/\" onclick=\"launch_popup(95, 640, 492); return false;\" target=\"_blank\"><img src=\"http://www.montanalinux.org/files/images/qemu10.thumbnail.jpg\" alt=\"Doing Updates\" title=\"Doing Updates\" class=\"image thumbnail\" width=\"100\" height=\"77\" /></a><span class=\"caption\" style=\"width: 98px;\">Doing Updates</span></span>Seeing 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.</p>\n<p>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.</p>\n<p>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?!?</p>\n<p>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.</p>\n<br class=\"clear\" />', created = 1410975775, expire = 1411062175, headers = '' WHERE cid = 'filter:1:5564b39d88dff6326fc88398376eb700' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: SELECT data, created, headers, expire FROM cache WHERE cid = 'filter:1:7f7437120ad888df21c16477fd661588' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: UPDATE cache SET data = '<p>talking about speed. What ya think which image format is the fastest and best in performance. Raw, qcow1 or qcow2.</p>\n<br class=\"clear\" />', created = 1410975775, expire = 1411062175, headers = '' WHERE cid = 'filter:1:7f7437120ad888df21c16477fd661588' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: SELECT data, created, headers, expire FROM cache WHERE cid = 'filter:1:923da62484767b10d3bdd3b26cb8fe8a' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: UPDATE cache SET data = '<p>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.</p>\n<p>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.</p>\n<br class=\"clear\" />', created = 1410975775, expire = 1411062175, headers = '' WHERE cid = 'filter:1:923da62484767b10d3bdd3b26cb8fe8a' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: SELECT data, created, headers, expire FROM cache WHERE cid = 'filter:3:8814f9538dcdd2134252589dd25f1ca0' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: UPDATE cache SET data = '<p>Hello Scott,</p>\n<p>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. </p>\n<p>I mention this because in my quest to install Slax to a USB I found, <a href=\"http://www.pendrivelinux.com\">www.pendrivelinux.com</a>. 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. </p>\n<p>Unfortunately, tonight the <a href=\"http://www.slax.org/\">SLAX</a> website is down. I\'m sure it\'ll be back soon.</p>\n<p>Thomas</p>\n', created = 1410975775, expire = 1411062175, headers = '' WHERE cid = 'filter:3:8814f9538dcdd2134252589dd25f1ca0' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: SELECT data, created, headers, expire FROM cache WHERE cid = 'filter:1:6072ee70c71c81828a41135b07922e9f' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: UPDATE cache SET data = '<p>I was cruising the <a href=\"http://fedoraproject.org/people/\" target=\"_fpsite\">Fedora People</a> site the other day and ran across an entry regarding <a href=\"http://www.gnome.org/~markmc/qemu-networking.html\" target=\"_qemunetarticle\">QEMU Networking</a> that I thought would come in handy for anyone wanting to do fancy networking stuff with QEMU.</p>\n<p>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.</p>\n<br class=\"clear\" />', created = 1410975775, expire = 1411062175, headers = '' WHERE cid = 'filter:1:6072ee70c71c81828a41135b07922e9f' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: SELECT data, created, headers, expire FROM cache WHERE cid = 'filter:1:a041c5563d2cc4461d1607791a7c7d9f' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
  • user warning: Table 'cache' is marked as crashed and should be repaired query: UPDATE cache SET data = '<p>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. </p>\n<p>If anybody does install the kernel module for QEMU please report if there is any speed increase. I would be interested in knowing.</p>\n<p> _<br />\n/-\\ ndrew</p>\n<br class=\"clear\" />', created = 1410975775, expire = 1411062175, headers = '' WHERE cid = 'filter:1:a041c5563d2cc4461d1607791a7c7d9f' in /home/dowdle/public_html/montanalinux/includes/database.mysql.inc on line 121.
| |

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.