User Mode Emulation
QEMU has two operation modes, Full System Emulation and User mode emulation.
In User mode emulation mode (Linux host only), QEMU can launch Linux processes compiled for one CPU on another CPU. It can be used e.g.to launch the Wine Windows API emulator or to ease cross-compilation and cross-debugging.
|~~~~~~~~~~~~~~~~~~~~~| | | | Applications | | | +---------------------+ ^^^ QEMU user mode emulation ^^^ | | | Kernel/OS | | | +---------------------+ | | | Hardware | | (CPU & Peripherals) | | | +---------------------+
Example
User mode emulation is the not so frequent usage mode of QEMU. However, as mentioned above, it is very nice to ease cross-compilation and cross-debugging. It is used, for example, in:
Usage
This section gives a short usage example, how to use QEMU user mode emulation to run a simple hello world example cross-compiled for ARM on x86 processor.
Download, configure and build QEMU user mode emulation. Available user mode emulations can be get by -M configure option:
> ./configure -M ... target list i386-user arm-user armeb-user sparc-user ppc-user mips-user mipsel-user ...
For this example, we want ARM:
> ./configure --target-list=arm-user > make
Now, you should have arm-user/qemu-arm executable.
Then, create a simple ARM example (you need a cross-compiler for this):
> cat hello_world.c
#include <stdio.h>
int main(void) {
printf("Hello world\n");
return 0;
}
> arm-linux-gcc hello_world.c -o hello_world
> file hello_world hello_world: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped
Then you can execute this ARM binary on x86 host using QEMUs user mode emulation:
> arm-user/qemu-arm -L /path_to_ld_so hello_world Hello world
Back to FrontPage