Qemu with kqemu kernel module support

From openSUSE


Geeko This HOWTO explains how to obtain and start kqemu.
The qemu is a processor emulator that is used to run an x86 Linux Kernel on x86 Linux.
The kqemu is kernel module that provides acceleration to qemu.


Contents


Why kqemu?

While qemu runs as stand alone application, it is rather slow. With acceleration module it is few times faster which brings speed in acceptable range.


Procedure openSUSE 10.3

Note: The kqemu since version 1.3.0pre10 it is under the GPL (version 2), and it is included in distribution now.

Setup

  • Install qemu and kqemu, using YaST or zypper.
  • Load acceleration module:
sudo modprobe kqemu

The sudo will ask you for a root password. Give it, and module will be loaded.

Troubleshooting

Mouse problem

If your mouse stay in a corner of the screen (window), run:

export SDL_VIDEO_X11_DGAMOUSE=0

before you start qemu.


Procedure for earlier versions

Note: The kqemu was not included in earlier versions of openSUSE/SUSE Linux.

openSUSE 10.2

The default version of GCC provided by openSUSE 10.2 compiles kqemu just fine. Just follow these steps:

Step 0:

  • Install the default version of QEMU from yast,smart,yum or however you manage your packages. Such as qemu-0.8.2-34.2.rpm

Step 1:

wget -c http://fabrice.bellard.free.fr/qemu/kqemu-1.3.0pre11.tar.gz
tar -zxvf kqemu-1.3.0pre11.tar.gz

Step 2:

cd kqemu-1.3.0pre11
./configure --prefix=/usr/local --enable-adlib \
--target-list="i386-user arm-user armeb-user sparc-user ppc-user i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu mips-softmmu"

Step 3:

make
sudo make install

Step 4:

sudo /sbin/modprobe kqemu major=0

The biggest drawback to not having an rpm for KQEMU for openSUSE 10.2 is the fact that each kernel upgrade requires the recompilation of the module. The steps for recompilation are as follows:

Step 0:

cd kqemu-1.3.0pre11
make clean

Step 1:

 ./configure --prefix=/usr/local --enable-adlib \
--target-list="i386-user arm-user armeb-user sparc-user ppc-user i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu mips-softmmu"

Step 2:

make
sudo make install

Step 3:

sudo /sbin/modprobe kqemu major=0

SUSE Linux 10.1

  • Just get the qemu rpm from one of your YaST repositories. This should work fine in most cases.
  • Alas, the QEMU Accelerator Module does not work from that. You will have to compile it yourself. Be sure it's version is compatible to that of your qemu rpm.
  • Firstly, get yourself the GCC-3.3.6 as described for SuSE Linux 10.0
  • Now commence with the QEMU Accelerator Module as described above for SuSE Linux 10.2
    make
    make install
  • You should be done now. Make sure that /dev/kqemu is set up.

SUSE Linux 10.0

The kqemu is not on the SUSE 10.0, distribution because of it's license.

GCC-3.3.6

Qemu doesn't compile with the default GCC provided by SUSE 10.0. You need to get gcc-3.3.6 and compile it.


This is true, but I do recommend to use the fixed version of qemu instead, which comes with SUSE Linux and got compiled with the official compiler. It can get downloaded here: http://download.opensuse.org/distribution/SL-10.0-OSS/inst-source/suse/i586/qemu-0.7.1-4.i586.rpm

AdrianSuSE 03:21, 25 Oct 2005 (MDT)

The fixed version of qemu that comes with SuSE Linux does not include the kqemu kernel module. It doesn't seem possible to use the kqemu sources with the source RPM provided by SuSE to build the module with the official compiler.

israelpattison 09:34, 08 Nov 2005 (EST)

Getting GCC-3.3.6

Get gcc-core from [1] or any other mirror from GCC Mirrors Page

Compiling GCC-3.3.6

Untar the source then configure with:
./configure --prefix=/opt/gcc33 --program-suffix=-3.3
WARNING: Do NOT configure it with the default prefix! It is recommended to compile it with this prefix else you can damage your system!
Now compile it with make bootstrap and after that install it with make install.

qemu and kqemu

Getting qemu and kqemu

Get qemu and kqemu from [2].

Compiling qemu and kqemu

Unpack qemu then change directory to the qemu directory. Here untar the kqemu archive. Now, let's configure it:
./configure --help will show you all options available.
Now let's discuss about what options we need. We need to specify which compiler to use and we will do this using --cc=/opt/gcc33/bin/gcc-3.3. We also need Adlib emulation: --enable-adlib. If you want full support you can configure it using the following command:
./configure --prefix=/usr/local --cc=/opt/gcc33/bin/gcc-3.3 --enable-adlib --target-list="i386-user arm-user armeb-user sparc-user ppc-user i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu mips-softmmu"<

Installing qemu and kqemu

After qemu has been configured you need to run:
make
make install

Once qemu and kqemu finish installing you still need to load the kqemu module in order to use it. Enter:
modprobe kqemu major=0
To verify that kqemu is loaded enter:
lsmod | grep kqemu
You should get a response back.

Verify the existence of /dev/kqemu. Enter:
ls -l /dev/kqemu
. You should get
crw-rw---- 1 root root 10, 62 2006-01-26 15:23 /dev/kqemu

If you want to use kqemu as normal user you must set (as root) read-write permissions to /dev/kqemu. To do that :
1. Become root with the command su
2. Enter:chmod a+rw /dev/kqemu

Now if you enter ls -l /dev/kqemu you should get
crw-rw-rw- 1 root root 10, 62 2006-01-26 15:23 /dev/kqemu

Verifying kqemu acceleration

Once you have kqemu acceleration installed you may want to verify that qemu is actually using it. Using the instructions[3] to start using qemu. Inside the qemu window hold down Ctrl+Alt and press 2. In the terminal that is now visible type:
info kqemu
You should get the response kqemu is enabled
If you did not then kqemu acceleration is not working. To return back to the normal qemu screen simply hold down Ctrl+Alt and press 1.

Last words

If you feel there's something wrong in this article or there's more to say about qemu and kqemu feel free to make your additions/corrections.

Passed QA check: --Shayon 18:32, 21 October 2009 (UTC)