qemu-wrapper

qemu wrapper used for specifying args to qemu-user in chroots
git clone git://parazyd.org/qemu-wrapper.git
Log | Files | Refs | README

commit 5186626b75daaa8eb62087015b348ff45c457ae1
parent 07db6d6b70d6a885c7b2722c95f336e08c327c4a
Author: parazyd <parazyd@dyne.org>
Date:   Fri,  8 Apr 2016 04:33:55 +0200

code and info

Diffstat:
MREADME.md | 11++++++++++-
Aqemu-wrapper.c | 20++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md @@ -1,2 +1,11 @@ # qemu-wrapper -wrapper for executing qemu in build chroots + +A simple wrapper for executing qemu in chroot builds. +With this, it is possible to pass arguments to qemu on chrooting, for example: +the cpu we wish to emulate. + +# Usage +Compile qemu wrapper with the below command and place it in `chroot/usr/bin/` +``` +gcc -static qemu-wrapper.c -Os -s -o qemu-wrapper +``` diff --git a/qemu-wrapper.c b/qemu-wrapper.c @@ -0,0 +1,20 @@ +/* qemu wrapper + * wrapper for executing qemu in build chroots + * pass arguments to qemu binary + * + * ~ parazyd */ + +#include <string.h> +#include <unistd.h> + +int main(int argc, char **argv, char **envp) { + char *newargv[argc + 3]; + + newargv[0] = argv[0]; + newargv[1] = "-cpu"; + newargv[2] = "cortex-a8"; /* here you can set the cpu you are building for */ + + memcpy(&newargv[3], &argv[1], sizeof(*argv) * (argc -1)); + newargv[argc + 2] = NULL; + return execve("/usr/bin/qemu-arm", newargv, envp); +}