How to build QEMU on Dapper?

I wanted to build qemu-0.8.1 and the latest kqemu kernel module, but I haven’t yet figured how the heck to reconcile these facts:

  • When you run ./configure on a Dapper system, QEMU complains that gcc4 is not recommended. I can disable that check and build with gcc4, but then the build fails with a super gnarly error about register spilling. So it seems that I have to use gcc3.
  • The kqemu kernel module needs to be built to match your kernel and thus must be built with the same compiler that the kernel was built with.
  • My kernel was built with gcc4:
    marc@tbird:~/qemu-0.8.1$ cat /proc/version 
    Linux version 2.6.15-25-686 (buildd@terranova) (gcc version 4.0.3 
    (Ubuntu 4.0.3-1ubuntu5)) #1 SMP PREEMPT Wed Jun 14 11:34:19 UTC 2006

    As a result, I can build qemu and the kernel module with gcc3, but I can’t load the kernel module:

    marc@tbird:~/qemu-0.8.1/kqemu-1.3.0pre9$ sudo modprobe kqemu
    FATAL: Error inserting kqemu (/lib/modules/2.6.15-25-686/misc/kqemu.ko): 
    Invalid module format
  • Any ideas on how to make this work?

    Update: Chimpoid has the answer below! Just build qemu with gcc3 and the kqemu module with gcc4. Works great.

4 thoughts on “How to build QEMU on Dapper?

  1. Copied from Geekpit
    Debian but it should work ok in Dapper.

    You need GCC version 3.x to build qemu, GCC version 4.x will not work. You can pass a different compiler to the configure script as ‘./configure –cc=/usr/bin/gcc-3.4’. Run ‘apt-cache search gcc’ to view a list of installable gcc versions. Further complicating things, if you are running a kernel compiled with gcc 4.x, you need to re-compile kqemu with gcc 4.x after compiling qemu with gcc 3.x. You can do this by re-running the ‘configure’ script without the ‘–cc’ option and with the ‘–disable-gcc-check’ option from the main qemu source directory, then type ‘cd kqemu && make clean && sudo make install’. This will build and install kqemu using gcc 4.x.

  2. simply build qemu with gcc3 and kqemu with gcc4. As of qemu-0.8.2 a kqemu-1.3.0pre9 it is very easy since compilation of kqemu is separate.

  3. You know, I just attempted to update from QEMU 0.8.2 to 0.9.0. 0.8.2 built fine for me with GCC 4, but 0.9.0 errors out. I went around to search and I found this. 🙂

    I am trying to see if it will build even with GCC 3, though, which seems to be a little bit of a war in and of itself. There seems to be some functionality that simply does not compile at all in the 0.9.0 release. Hopefully, my virtual machines will run just fine.

    It is kind of annoying that GCC 3 has to be kept around for this one particular program. (And even worse, GCC 3 can’t properly be detected by the configure script that comes with QEMU 0.9.0, too.) And that the KQEMU module has to be built with the same version of GCC as the kernel… grr!

    I started to wonder if it would be possible to make QEMU able to build properly under GCC 4, but then I realized that I would be able to do nothing to help; the program deals with things that I could not even begin to imagine wrapping my head around. 🙂

Leave a Reply

Your email address will not be published.