<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Weiqi Gao&#039;s Observations - qemu tag</title>
  <link>http://www.weiqigao.com/blog/tags/qemu/</link>
  <description>Sharing My Experience...</description>
  <language>en</language>
  <copyright>Weiqi Gao</copyright>
  <lastBuildDate>Fri, 11 May 2012 12:48:36 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  <image>
    <url>http://pebble.sourceforge.net/common/images/powered-by-pebble.gif</url>
    <title>Weiqi Gao&#039;s Observations</title>
    <link>http://www.weiqigao.com/blog/</link>
  </image>
  
  
  <item>
    <title>QEMU: The Open Source Virtualizer</title>
    <link>http://www.weiqigao.com/blog/2007/11/27/qemu_the_open_source_virtualizer.html</link>
    
      
        <description>
          &lt;p&gt;According to its &lt;a href= &#034;http://fabrice.bellard.free.fr/qemu/&#034; &gt;home page&lt;/a&gt;, &#034;QEMU is a generic and open source machine emulator and virtualizer.&#034;&lt;/p&gt;

&lt;p&gt;I started playing with QEMU 695 days ago, and have made three posts about QEMU:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href= &#034;http://www.weiqigao.com/blog/2006/02/20/qemu_the_open_source_processor_emulator.html&#034; &gt;QEMU: The Open Source Processor Emulator&lt;/a&gt; (648 days ago)&lt;/li&gt;
&lt;li&gt;&lt;a href= &#034;http://www.weiqigao.com/blog/2006/05/02/qemu_just_how_fast_is_it.html&#034; &gt;QEMU: Just How Fast Is It?&lt;/a&gt; (577 days ago)&lt;/li&gt;
&lt;li&gt;&lt;a href= &#034;http://www.weiqigao.com/blog/2006/05/21/qemu_gentoo_guest_performance.html&#034; &gt;QEMU: Gentoo Guest Performance&lt;/a&gt; (558 days ago)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unlike treating it like many of the other technologies that I took a look and then forgot about, I kept on using it as an emulator to run some of my non-GNU/Linux software.  The software I want to run were pretty old, so they run at a reasonable speed even in emulator mode (1/20 native speed).  I wrote WQGHLT along the way, which you can find &lt;a href= &#034;http://www.weiqigao.com/software/&#034; &gt;here&lt;/a&gt; under GPLv2.&lt;/p&gt;

&lt;p&gt;To run QEMU in virtualizer mode would require a piece of software called the KQEMU host driver, which was not available in open source form at the time.  So I did not experiment.  Another option for QEMU acceleration is through the kvm feature of a recent Linux kernel.  But that requires a CPU that has hardware support for virtualization, which my AMD64 does not have.&lt;/p&gt;

&lt;p&gt;KQEMU version 1.3.0pre11 was &lt;a href= &#034;http://fabrice.bellard.free.fr/qemu/index.html&#034; &gt;released under the GPLv2&lt;/a&gt; on February 6, 2007.  And it turns out that it is possible to have a QEMU/KQEMU combination running (and the guest running at 76% native speed according to the dhry2 benchmark) under Debian 4.0 x86_64.  However, as everything Debian, the complete information for getting this setup working is scattered around the internet, and I have to do some digging and carbon-dating.&lt;/p&gt;

&lt;p&gt;The good news is that both QEMU and KQEMU are available in Debian 4.0 Etch (&lt;a href= &#034;http://packages.debian.org/stable/allpackages&#034; &gt;QEMU 0.8.2/KQEMU 1.3.0pre9&lt;/a&gt;) and unstable (&lt;a href= &#034;http://packages.debian.org/unstable/allpackages&#034; &gt;QEMU 0.9.0 and/KQEMU 1.3.0pre11&lt;/a&gt;).  The bad news is that the &lt;a href= &#034;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=402289&#034; &gt;packaged combination does not work&lt;/a&gt;; I saw the kernel panic in the guest OS when I tried.  The compromise is to use the KQEMU from Debian unstable repository and the source release from QEMU website.&lt;/p&gt;

&lt;p&gt;My recipe follows.&lt;/p&gt;

&lt;h4&gt;Preperations&lt;/h4&gt;

&lt;p&gt;I outlined how I changed my APT settings in the &lt;a href= &#034;http://www.weiqigao.com/blog/2007/11/04/getting_sun_java_6_on_debian_4_0_with_apt_pinning.html&#034; &gt;Getting Sun Java 6 On Debian 4.0 With APT Pinning&lt;/a&gt; post that I made 26 days ago.  I did not change any of the settings this time.&lt;/p&gt;

&lt;h4&gt;Installing KQEMU&lt;/h4&gt;

&lt;p&gt;There are numerous web pages that describes how to install a kernel module using the &lt;tt&gt;module-assistant&lt;/tt&gt; (aka &lt;tt&gt;m-a&lt;/tt&gt;) command.  I adapted the instructions in &lt;a href= &#034;http://wiki.debian.org/DebianEdu/HowTo/TestCDinstall&#034; &gt;this page&lt;/a&gt;:&lt;/p&gt;

&lt;pre style=&#034;margin-left:3em&#034;&gt;[root@gao-2006]# &lt;b&gt;feta install qemu-common/unstable&lt;/b&gt;
[root@gao-2006]# &lt;b&gt;feta install qemu-source/unstable&lt;/b&gt;
[root@gao-2006]# &lt;b&gt;m-a prepare&lt;/b&gt;
[root@gao-2006]# &lt;b&gt;m-a build kqemu-source&lt;/b&gt;
[root@gao-2006]# &lt;b&gt;m-a install kqemu-source&lt;/b&gt;
[root@gao-2006]# &lt;b&gt;modprobe kqemu&lt;/b&gt;
[root@gao-2006]# &lt;b&gt;echo kqemu &gt;&gt; /etc/modules&lt;/b&gt;&lt;/pre&gt;

&lt;p&gt;Note that I used the &lt;a href= &#034;http://savannah.nongnu.org/projects/feta/&#034; &gt;&lt;tt&gt;feta&lt;/tt&gt;&lt;/a&gt; command to do the work of &lt;tt&gt;apt-get&lt;/tt&gt;, as Jonathan excellently suggested &lt;a href= &#034;http://www.weiqigao.com/blog/2007/06/19/goodbye_fedora_hello_debian.html#comment1182256056169&#034; &gt;164 days ago&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I did not include the output from the above commands.  Let me just say that the outputs are long, informative, upbeat, and colorful.  When everything is done, I have a &lt;tt&gt;kqemu-modules-2.6.18-5-amd64&lt;/tt&gt; package built and installed, with the kqemu kernel module installed at &lt;tt&gt;/lib/modules/2.6.18-5-amd64/misc/kqemu.ko&lt;/tt&gt;.  A &lt;tt&gt;/dev/kqemu&lt;/tt&gt; entry is created with the following characteristics:&lt;/p&gt;

&lt;pre style=&#034;margin-left:3em&#034;&gt;crw-rw-rw- 1 root root 10, 62 2007-11-28 09:11 /dev/kqemu&lt;/pre&gt;

&lt;p&gt;The output of the &#034;&lt;tt&gt;lsmod | grep kqemu&lt;/tt&gt;&#034; command indicates that the KQEMU kernal module is indeed loaded, but is not currently being used by any programs.&lt;/p&gt;

&lt;h4&gt;Downloading and compiling QEMU&lt;/h4&gt;

&lt;p&gt;I downloaded &lt;a href= &#034;http://fabrice.bellard.free.fr/qemu/qemu-0.9.0.tar.gz&#034; &gt;QEMU 0.9.0 source&lt;/a&gt; from the &lt;a href= &#034;http://fabrice.bellard.free.fr/qemu/download.html&#034; &gt;QEMU download page&lt;/a&gt;.  It has the standard &lt;tt&gt;./configure&lt;/tt&gt;, &lt;tt&gt;make&lt;/tt&gt;, &lt;tt&gt;make install&lt;/tt&gt; installation sequence.  The only peculiarity is that QEMU requires GCC 3.x and SDL library to build.  This is easily fixed by installing the &lt;tt&gt;gcc-3.4&lt;/tt&gt; and &lt;tt&gt;libsdl-console-dev&lt;/tt&gt; packages and their dependencies.&lt;/p&gt;

&lt;p&gt;The configure process informs me that kqemu support is enabled.&lt;/p&gt;

&lt;p&gt;The build process produces the following set of executables:&lt;/p&gt;

&lt;pre style=&#034;margin-left:3em&#034;&gt;[root@gao /opt/qemu-0.9.0/bin]# &lt;b&gt;ls&lt;/b&gt;
&lt;span style=&#034;color:green&#034;&gt;qemu        qemu-img     qemu-ppc          qemu-system-mipsel
qemu-arm    qemu-m68k    qemu-sparc        qemu-system-ppc
qemu-armeb  qemu-mips    qemu-system-arm   qemu-system-sparc
qemu-i386   qemu-mipsel  qemu-system-mips  qemu-system-x86_64&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;I also needed to install the &lt;tt&gt;texlive&lt;/tt&gt; package and its dependencies to make the documentation.&lt;/p&gt;

&lt;h4&gt;Running QEMU in virtualizer mode&lt;/h4&gt;

&lt;p&gt;On the x86_64 platform, the kqemu module &lt;a href= &#034;http://fabrice.bellard.free.fr/qemu/kqemu-doc.html#SEC6&#034; &gt;can only be activated&lt;/a&gt; by the &lt;tt&gt;qemu-system-x86_64&lt;/tt&gt; program.  There are two command line arguments for &lt;tt&gt;qemu-system-x86_64&lt;/tt&gt; that control its behavior:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;b&gt;(no argument)&lt;/b&gt;: Only user code is executed directly; kernel code is dynamically translated&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;tt&gt;-kernel-kqemu&lt;/tt&gt;&lt;/b&gt;: Both user code and kernel code are executed directly (full vertualization mode)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;tt&gt;-no-kqemu&lt;/tt&gt;&lt;/b&gt;: Both user code and kernel code are dynamically translated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When &lt;tt&gt;qemu-system-x86_64&lt;/tt&gt; runs, &#034;&lt;tt&gt;lsmod | grep kqemu&lt;/tt&gt;&#034; shows that the kqemu kernel module is indeed being used:&lt;/p&gt;

&lt;pre style=&#034;margin-left:3em&#034;&gt;[root@gao-2006]# &lt;b&gt;lsmod | grep kqemu&lt;/b&gt;
kqemu                 170120  1&lt;/pre&gt;

&lt;h4&gt;Benchmarks&lt;/h4&gt;

&lt;p&gt;I rerun the &lt;a href= &#034;http://www.anime.net/~goemon/benchmarks.html&#034;&gt;benchmark&lt;/a&gt; program inside a Debian 4.0 i386 guest OS.  And the result is captured in this screenshot:&lt;/p&gt;

&lt;center&gt;
&lt;a href= &#034;./images/kqemu-debian-i386-performance.png&#034; &gt;
&lt;img src=&#034;http://www.weiqigao.com/blog/images/kqemu-debian-i386-performance.png&#034; title=&#034;QEMU Full Virtualization Mode Performance&#034; width=&#034;689&#034; height=&#034;533&#034; /&gt;&lt;/a&gt;
&lt;/center&gt;

&lt;p&gt;A comparison with &lt;a href= &#034;http://www.weiqigao.com/blog/2006/05/21/qemu_gentoo_guest_performance.html&#034; &gt;my earlier results&lt;/a&gt; shows that the result of 219.0 dhrystone for QEMU in full virtualization mode is 18.4 times the 11.9 dhrystone for QEMU in emulator mode.  Note that these benchmarks were run on the same physical hardware.&lt;/p&gt;

&lt;p&gt;The benchmark result ran in the host OS is 288.6 dhrystone.&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2007/11/27/qemu_the_open_source_virtualizer.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2007/11/27/qemu_the_open_source_virtualizer.html</guid>
    <pubDate>Wed, 28 Nov 2007 04:23:00 GMT</pubDate>
  </item>
  
  <item>
    <title>QEMU: Gentoo Guest Performance</title>
    <link>http://www.weiqigao.com/blog/2006/05/21/qemu_gentoo_guest_performance.html</link>
    
      
        <description>
          &lt;p&gt;It took me 12 days (not months as I &lt;a href= &#034;http://www.weiqigao.com/blog/2006/05/02/qemu_just_how_fast_is_it.html#comment1146660074171&#034; &gt;previously guessed&lt;/a&gt;) but I have an instance of &lt;a href= &#034;http://www.gentoo.org/&#034; &gt;Gentoo&lt;/a&gt; installed as a &lt;a href= &#034;http://fabrice.bellard.free.fr/qemu/&#034; &gt;QEMU&lt;/a&gt; guest.  That includes the time of the initial installation of Gentoo, which went very smoothly due to their &lt;a href= &#034;http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&amp;chap=1&#034; &gt;superb documentation&lt;/a&gt;, the emergence of links the terminal mode web browser, which brought in more than 200 dependencies including the entire X Window System, and a failed attempt to emerge Gnome, which would have brought in another 250 packages but errored out when there are 100 to go.  (After the failed Gnome installation, I wanted to clean up a bit and retry.  One of the cleanup commands I used is &lt;tt&gt;emerge --depclean&lt;/tt&gt;, which wiped out the 150 packages already installed for Gnome.)&lt;/p&gt;

&lt;p&gt;And here&#039;s the benchmark result:&lt;/p&gt;

&lt;center&gt;
&lt;a href= &#034;./images/qemu-gentoo-2006.0.png&#034; &gt;
&lt;img src= &#034;./images/qemu-gentoo-2006.0.png&#034; title= &#034;Gentoo 2006.0 Under QEMU&#034; border=&#034;0&#034; /&gt;
&lt;/a&gt;
&lt;/center&gt;

&lt;p&gt;On the surface, Gentoo&#039;s index of 11.9 compares unfavorably against &lt;a href= &#034;http://www.weiqigao.com/blog/images/qemu-ubuntu-6.06.png&#034; &gt;Ubuntu&#039;s 56.0&lt;/a&gt;.  However, on close inspection, I discovered that the Ubuntu guest&#039;s clock is running much slower then the host&#039;s clock, which inflated Ubuntu&#039;s index.&lt;/p&gt;

&lt;p&gt;An rough estimate shows that Ubuntu&#039;s clock is running at one quarter of the regular clock speed.  So the Ubuntu number should be roughly 14.0, still better than the Gentoo number.  Incidentally, with the new lower number, the emulated QEMU system falls into the Pentium 200 category.&lt;/p&gt;

&lt;p&gt;So for all that long compile time, I get a Gentoo system that runs at 85% the speed of Ubuntu.  Apparently for the system emulated by QEMU, none of the optimizations that I hear Gentoo enthusiasts talking about matters.&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2006/05/21/qemu_gentoo_guest_performance.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2006/05/21/qemu_gentoo_guest_performance.html</guid>
    <pubDate>Sun, 21 May 2006 16:04:07 GMT</pubDate>
  </item>
  
  <item>
    <title>QEMU: Just How Fast Is It?</title>
    <link>http://www.weiqigao.com/blog/2006/05/02/qemu_just_how_fast_is_it.html</link>
    
      
        <description>
          &lt;p&gt;I last blogged about my &lt;a href= &#034;http://www.weiqigao.com/blog/2006/02/20/qemu_the_open_source_processor_emulator.html&#034; &gt;experience&lt;/a&gt; with &lt;a href= &#034;http://fabrice.bellard.free.fr/qemu/&#034; &gt;QEMU&lt;/a&gt; 71 days ago.&lt;/p&gt;

&lt;p&gt;Since then I have brought up several other operating systems on it, including NT 4.0, Windows 2000 and FreeBSD 6.0.  One thing I noticed is that the newer OSes has more demand on the system and therefore behaves more sluggishly, to the point of not being very useful.&lt;/p&gt;

&lt;p&gt;My latest adventure with QEMU is a &lt;a href= &#034;http://www.weiqigao.com/blog/2005/12/12/ubuntu_5_10_first_impression.html&#034; &gt;second try&lt;/a&gt; at &lt;a href= &#034;http://www.ubuntu.com/&#034; &gt;Ubuntu&lt;/a&gt; 6.06 Beta (Dapper Drake).&lt;/p&gt;

&lt;p&gt;Maybe it&#039;s because I have experienced Ubuntu once before, or maybe it&#039;s because Ubuntu 6.06 Beta is really that much better than 5.10, or maybe it&#039;s because I&#039;m getting a little bit impatient with &lt;a href= &#034;http://www.weiqigao.com/blog/2006/03/26/fedora_core_5_desktop_moving_backwards.html&#034; &gt;Fedora Core 5&#039;s degradations&lt;/a&gt;, my impression of Ubuntu has improved, even though it&#039;s running very slowly under QEMU.&lt;/p&gt;

&lt;p&gt;To measure how much slower the emulated system is compared with the host system, I ran a little bench mark program that &lt;a href= &#034;http://www.anime.net/~goemon/benchmarks.html&#034; &gt;I found on the internet&lt;/a&gt;.  The result can be found in the screenshot below:&lt;/p&gt;

&lt;center&gt;
&lt;a href= &#034;./images/qemu-ubuntu-6.06.png&#034; &gt;
&lt;img src= &#034;./images/qemu-ubuntu-6.06-small.png&#034; title=&#034;Ubuntu 6.06 Beta Under QEMU&#034; border=&#034;0&#034; /&gt;
&lt;/a&gt;
&lt;/center&gt;

&lt;p&gt;The bench mark index is 294.0 on the host OS and 56.0 on the guest OS.  So the guest is running at 19% of the speed of the host system, making my AMD64 3500+ look like a P3/700MHz.&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2006/05/02/qemu_just_how_fast_is_it.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2006/05/02/qemu_just_how_fast_is_it.html</guid>
    <pubDate>Wed, 03 May 2006 04:08:46 GMT</pubDate>
  </item>
  
  </channel>
</rss>

