Previous: Set up the KVM host system.

To run KVM, you need to build QEMU for ARM. There are several possibilities here:

  • build it on native ARM hardware and copy the binary across (should work but not everybody has conveniently set up native hardware)
  • run Linux on the Fast Model and build it natively there (should work but will be painfully slow)
  • build under QEMU chroot (runs into QEMU bugs at the moment)
  • cross compile (tedious to set up and disables a lot of options like SDL support)

This page documents how to do this as a cross compilation.

If you haven't already, install the cross compiler:

$ sudo apt-get install gcc-arm-linux-gnueabihf  binutils-arm-linux-gnueabihf libc6-armhf-cross linux-libc-dev-armhf-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross cpp-arm-linux-gnueabihf

Install some native build dependencies:

$ sudo apt-get build-dep qemu-linaro
$ sudo apt-get install libfdt-dev

(This pulls in more than necessary but is an easy way to do it).

We'll use xapt to create and install cross versions of libz and glib, which is the minimal set of dependencies QEMU need (assuming you already have qemu-user-static installed):

$ sudo apt-get install xapt

First create a new file /etc/apt/sources.list.d/armhf-trusty.list with the following contents:

deb [arch=armhf] trusty main restricted universe multiverse
deb-src [arch=armhf] trusty main restricted universe multiverse

Then run

$ sudo xapt -a armhf -m -b zlib1g-dev libglib2.0-dev libfdt-dev

This will build a pile of 37 _all debs in /var/lib/xapt/output/; we need most of them, so it's easiest to install them all:

$ sudo dpkg -i /var/lib/xapt/output/*.deb

Put this arm-linux-gnueabihf-pkg-config script on your PATH somewhere, and make it executable, eg:

$ chmod a+x /usr/local/bin/arm-linux-gnueabihf-pkg-config

Get and build QEMU:

$ git clone git:// qemu
$ cd qemu
$ mkdir arm-build
$ cd arm-build
$ ../configure --cross-prefix=arm-linux-gnueabihf- --target-list=arm-softmmu --enable-kvm
$ make
$ sudo make install DESTDIR=/srv/arm-trusty-root

This will build QEMU with the cross compiler and install it into the nfs root's /usr/local/bin.

Next: Set up the KVM guest system.

Core/Virtualization/HowTo/Arm32BuildQemu (last modified 2014-12-07 21:15:57)