Hi,
The v3 patch fix ident error and add error checking on
ptsname_r() function. This patch is based on version:
007e620a7576e4ce2ea6955541e87d8ae8ed32ae.
---
Building QEMU on android reqiures android NDK r10 cross-compilation
toolchain with following changes:
- install qemu dependent libraries
- upgrade bionic libc
- add mssing includes, scsi/sg.h, in toolchain
- make a symbolic link x86_64-linux-android-pkg-config that links
to host's pkg-config.
Then, configure and build static linked qemu by commands:
$ export SYSROOT="/opt/android-toolchain64/sysroot"
$ PKG_CONFIG_LIBDIR=/opt/android-toolchain64/sysroot/usr/lib/pkgconfig \
./configure \
--cross-prefix=x86_64-linux-android- --enable-kvm \
--enable-trace-backend=nop --disable-fdt --target-list=x86_64-softmmu \
--disable-spice --disable-vhost-net --disable-libiscsi \
--audio-drv-list="" --disable-gtk --disable-gnutls \
--disable-libnfs --disable-glusterfs --disable-libssh2 \
--disable-seccomp --disable-usb-redir --disable-libusb \
--disable-guest-agent --static
$ make -j4
For dynamic build, you can skip the "static" option during configure, copy
dependent so files into android and add "." into LD_LIBRARY_PATH.
How to prepare your cross-compilation toolcahin
---
1. Download NDK r10, install toolchain from NDK and build the following
libraries and install in your toolchain sysroot:
libiconv-1.14
gettext-0.19
libffi-3.0.12
glib-2.34.3
libpng-1.2.52
pixman-0.30
2. Download AOSP and apply this patch I made to support posix lockf()
https://android-review.googlesource.com/#/c/172150/
3. Build bionic C and update your toolchain's libc.a and libc.so.
4. Copy kernel header file, scsi/sg.h into toolchain's
sysroot/usr/includes/scsi/
5. Update these header files in your toolchain to prevent compilation warning,
includes:
unistd.h for lockf() and related define
sys/uio.h for pread() and pwrite()
signal.h for sigtimedwait()
Signed-off-by: Houcheng Lin
---
configure | 18 --
default-configs/pci.mak | 2 +-
hw/i386/kvm/pci-assign.c| 1 -
include/qemu/osdep.h| 7 +++
include/sysemu/os-android.h | 12
kvm-all.c | 4
tests/Makefile | 2 ++
util/oslib-posix.c | 12
util/qemu-openpty.c | 20 +++-
9 files changed, 69 insertions(+), 9 deletions(-)
create mode 100644 include/sysemu/os-android.h
diff --git a/configure b/configure
index d7c24cd..12e3402 100755
--- a/configure
+++ b/configure
@@ -567,7 +567,6 @@ fi
# host *BSD for user mode
HOST_VARIANT_DIR=""
-
case $targetos in
CYGWIN*)
mingw32="yes"
@@ -693,9 +692,20 @@ Haiku)
vhost_net="yes"
vhost_scsi="yes"
QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers
$QEMU_INCLUDES"
+ case $cross_prefix in
+*android*)
+ android="yes"
+;;
+*)
+;;
+ esac
;;
esac
+if [ "$android" = "yes" ] ; then
+ LIBS="-lglib-2.0 -lgthread-2.0 -lz -lpixman-1 -lintl -liconv -lc $LIBS"
+ libs_qga="-lglib-2.0 -lgthread-2.0 -lz -lpixman-1 -lintl -liconv -lc"
+fi
if [ "$bsd" = "yes" ] ; then
if [ "$darwin" != "yes" ] ; then
bsd_user="yes"
@@ -3791,7 +3801,7 @@ elif compile_prog "" "$pthread_lib -lrt" ; then
fi
if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
-"$aix" != "yes" -a "$haiku" != "yes" ; then
+"$aix" != "yes" -a "$haiku" != "yes" -a "$android" != "yes" ; then
libs_softmmu="-lutil $libs_softmmu"
fi
@@ -4737,6 +4747,10 @@ if test "$linux" = "yes" ; then
echo "CONFIG_LINUX=y" >> $config_host_mak
fi
+if test "$android" = "yes" ; then
+ echo "CONFIG_ANDROID=y" >> $config_host_mak
+fi
+
if test "$darwin" = "yes" ; then
echo "CONFIG_DARWIN=y" >> $config_host_mak
fi
diff --git a/default-configs/pci.mak b/default-configs/pci.mak
index 7e10903..e76dd41 100644
--- a/default-configs/pci.mak
+++ b/default-configs/pci.mak
@@ -35,5 +35,5 @@ CONFIG_SDHCI=y
CONFIG_EDU=y
CONFIG_VGA=y
CONFIG_VGA_PCI=y
-CONFIG_IVSHMEM=$(CONFIG_KVM)
+CONFIG_IVSHMEM=$(call land,$(call lnot,$(CONFIG_ANDROID)),$(CONFIG_KVM))
CONFIG_ROCKER=y
diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index b1beaa6..44beee3 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -22,7 +22,6 @@
*/
#include
#include
-#include
#include
#include
#include
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index ab3c876..f5be51c 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -59,6 +59,10 @@
#define WEXITSTATUS(x) (x)
#endif
+#ifdef CONFIG_ANDROID
+#include "sysemu/os-android.h"
+#endif
+
#ifdef _WIN32
#include "sysemu/os-win32.h"
#endif
@@ -284,4 +288,7 @@ void os_mem_prealloc