qemu on gentoo

I’m running gentoo on a pogoplug. This is an embedded device with 1,2GHz armv5 and 256MB Ram. Unfortunately, big packages like gcc don’t finish.

Thats why i set up a working qemu environment to emerge certain packages, zip them up, and unpack them on the working system.

So the aim is to modify a backup of the working system to emerge native binaries on my x86_64 host. For this, we have to succeed on the following 3 stages:

1. Run native ARM binaries

This is pretty simple. Just emerge qemu. It will propably work. Afterwards, try running a native arm binary. Just google “hello_world-arm-static”. Running

qemu-arm hello_world-arm-static
Should return “Hello world!”

The next step is

2. Register a specific handler for ARM binaries

The problem is that you still have to add “qemu-arm” in front of each binary to be executed. Linux can solve this problem by reading the first bytes included in each binary and using these bytes for a file-type decision. And what we want is to use qemu to open ARM-binaries.
The process is described in the official gentoo handbook. Just follow the description
Important: The wrapper script, which is registered to handle ARM-binaries, must exist in both environments. That is the host, and the ARM-architecture-backup which we are modifing right now.
Also, the binary has to be static.

You can test this step by executing ./hello_world-arm-static. This should work.

Finally, the step where i failed multiple times.

3. Compile a static qemu for both environments

In the first step, we could use any qemu-version we hat compiled. Now we want to chroot into the backup. There is no way to access libraries from the host system (at least, there should be no way).
Now, the qemu-version has to be static, including all dependencies. To succeed we remove all dependencies as we propably won’t need them anyway. Thus we avoid cluttering the host environment with static programs.
We still need the use flags “fdt static static-softmmu static-user”, the QEMU_SOFTMMU_TARGETS="arm" and
I ended up modifying /etc/portage/package.use/package.use with
app-emulation/qemu -aio -alsa -sdl static static-softmmu -bluetooth -opengl -caps -curl -filecaps -jpeg -lzo -ncurses -nfs -nls -opengl pin-upstream-blobs -png -python -seccomp -ssh -usb -uuid -vhost-net -vnc -threads

You can use quickpkg to distribute this package to the arm-backup using
ROOT=$PWD/ emerge -Kav qemu".

You can test this step by chrooting into your guest system.

Leave Comment

Your email address will not be published. Required fields are marked *