enable package: qemu-system

This commit is contained in:
Leonid Pliushch 2018-09-17 14:27:14 +03:00 committed by Yaksh Bariya
parent 2230588cf1
commit 67d96765b7
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
32 changed files with 858 additions and 0 deletions

View File

@ -0,0 +1,66 @@
TERMUX_PKG_MAINTAINER="Leonid Plyushch <leonid.plyushch@gmail.com> @xeffyr"
TERMUX_PKG_HOMEPAGE=https://www.qemu.org
TERMUX_PKG_DESCRIPTION="A generic and open source machine emulator and virtualizer (i386, x86_64 targets)"
TERMUX_PKG_VERSION=2.12.0
TERMUX_PKG_REVISION=3
TERMUX_PKG_SRCURL=https://download.qemu.org/qemu-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=e69301f361ff65bf5dabd8a19196aeaa5613c1b5ae1678f0823bdf50e7d5c6fc
TERMUX_PKG_DEPENDS="glib, libandroid-shmem, libandroid-support, libbz2, libc++, libcurl, libgnutls, libjpeg-turbo, liblzo, libnettle, libpixman, libpng, libsasl, libsdl, libssh2, libutil, ncurses"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_RM_AFTER_INSTALL="
bin/qemu-nbd
share/man/man8
"
termux_step_configure()
{
./configure --prefix="${TERMUX_PREFIX}" \
--cross-prefix="${CC//clang}" \
--cc="${CC}" \
--host-cc="gcc" \
--cxx="${CXX}" \
--objcc="${CC}" \
--extra-cflags="${CFLAGS}" \
--extra-cxxflags="${CXXFLAGS}" \
--extra-ldflags="${LDFLAGS} -landroid-shmem -llog" \
--smbd="${TERMUX_PREFIX}/bin/smbd" \
--disable-guest-agent \
--enable-pie \
--disable-gtk \
--disable-vte \
--enable-curses \
--enable-vnc \
--enable-vnc-jpeg \
--enable-vnc-png \
--enable-vnc-sasl \
--disable-mpath \
--disable-xen \
--enable-curl \
--enable-fdt \
--disable-kvm \
--disable-hax \
--disable-spice \
--enable-lzo \
--enable-bzip2 \
--disable-seccomp \
--enable-coroutine-pool \
--enable-tpm \
--enable-libssh2 \
--disable-jemalloc \
--disable-libxml2 \
--target-list=aarch64-softmmu,arm-softmmu,i386-softmmu,x86_64-softmmu
}
termux_step_post_make_install()
{
## by default, alias 'qemu' will be a qemu-system-x86_64
ln -sfr "${TERMUX_PREFIX}/bin/qemu-system-x86_64" "${TERMUX_PREFIX}/bin/qemu"
sed -i 's/qemu\\-system\\-i386/qemu\\-system\\-x86_64/g' "${TERMUX_PREFIX}/share/man/man1/qemu.1"
## symlink manpages
ln -sfr "${TERMUX_PREFIX}/share/man/man1/qemu.1" "${TERMUX_PREFIX}/share/man/man1/qemu-system-aarch64.1"
ln -sfr "${TERMUX_PREFIX}/share/man/man1/qemu.1" "${TERMUX_PREFIX}/share/man/man1/qemu-system-arm.1"
ln -sfr "${TERMUX_PREFIX}/share/man/man1/qemu.1" "${TERMUX_PREFIX}/share/man/man1/qemu-system-i386.1"
ln -sfr "${TERMUX_PREFIX}/share/man/man1/qemu.1" "${TERMUX_PREFIX}/share/man/man1/qemu-system-x86_64.1"
}

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/audio/ossaudio.c qemu-2.12.0.mod/audio/ossaudio.c
--- qemu-2.12.0/audio/ossaudio.c 2018-04-24 19:30:46.000000000 +0300
+++ qemu-2.12.0.mod/audio/ossaudio.c 2018-06-25 14:11:33.200632120 +0300
@@ -23,7 +23,7 @@
*/
#include "qemu/osdep.h"
#include <sys/ioctl.h>
-#include <sys/soundcard.h>
+#include <linux/soundcard.h>
#include "qemu-common.h"
#include "qemu/main-loop.h"
#include "qemu/host-utils.h"

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/block.c qemu-2.12.0.mod/block.c
--- qemu-2.12.0/block.c 2018-04-24 19:30:46.000000000 +0300
+++ qemu-2.12.0.mod/block.c 2018-06-25 14:11:33.210632119 +0300
@@ -544,7 +544,7 @@
const char *tmpdir;
tmpdir = getenv("TMPDIR");
if (!tmpdir) {
- tmpdir = "/var/tmp";
+ tmpdir = "@TERMUX_PREFIX@/var/tmp";
}
if (snprintf(filename, size, "%s/vl.XXXXXX", tmpdir) >= size) {
return -EOVERFLOW;

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/block/cloop.c qemu-2.12.0.mod/block/cloop.c
--- qemu-2.12.0/block/cloop.c 2018-04-24 19:30:46.000000000 +0300
+++ qemu-2.12.0.mod/block/cloop.c 2018-06-25 14:11:33.203965453 +0300
@@ -47,7 +47,7 @@
static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
{
- const char *magic_version_2_0 = "#!/bin/sh\n"
+ const char *magic_version_2_0 = "#!@TERMUX_PREFIX@/bin/sh\n"
"#V2.0 Format\n"
"modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n";
int length = strlen(magic_version_2_0);

View File

@ -0,0 +1,89 @@
diff -uNr qemu-2.12.0/configure qemu-2.12.0.mod/configure
--- qemu-2.12.0/configure 2018-04-24 19:30:46.000000000 +0300
+++ qemu-2.12.0.mod/configure 2018-06-25 14:46:22.550739693 +0300
@@ -2079,23 +2079,10 @@
LIBS="$LIBS -lz"
##########################################
-# lzo check
+# disable lzo check, force enable instead
-if test "$lzo" != "no" ; then
- cat > $TMPC << EOF
-#include <lzo/lzo1x.h>
-int main(void) { lzo_version(); return 0; }
-EOF
- if compile_prog "" "-llzo2" ; then
- libs_softmmu="$libs_softmmu -llzo2"
- lzo="yes"
- else
- if test "$lzo" = "yes"; then
- feature_not_found "liblzo2" "Install liblzo2 devel"
- fi
- lzo="no"
- fi
-fi
+libs_softmmu="$libs_softmmu -llzo2"
+lzo="yes"
##########################################
# snappy check
@@ -2117,22 +2104,9 @@
fi
##########################################
-# bzip2 check
+# disable bzip2 check, force enable bz2
-if test "$bzip2" != "no" ; then
- cat > $TMPC << EOF
-#include <bzlib.h>
-int main(void) { BZ2_bzlibVersion(); return 0; }
-EOF
- if compile_prog "" "-lbz2" ; then
- bzip2="yes"
- else
- if test "$bzip2" = "yes"; then
- feature_not_found "libbzip2" "Install libbzip2 devel"
- fi
- bzip2="no"
- fi
-fi
+bzip2="yes"
##########################################
# libseccomp check
@@ -2974,6 +2948,7 @@
# VNC SASL detection
if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
cat > $TMPC <<EOF
+#include <sys/types.h>
#include <sasl/sasl.h>
#include <stdio.h>
int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
@@ -4035,16 +4010,6 @@
##########################################
# signalfd probe
signalfd="no"
-cat > $TMPC << EOF
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <signal.h>
-int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
-EOF
-
-if compile_prog "" "" ; then
- signalfd=yes
-fi
# check if eventfd is supported
eventfd=no
@@ -5490,7 +5455,7 @@
# We can only support ivshmem if we have eventfd
if [ "$eventfd" = "yes" ]; then
- ivshmem=yes
+ ivshmem=no
fi
tools=""

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/contrib/ivshmem-client/main.c qemu-2.12.0.mod/contrib/ivshmem-client/main.c
--- qemu-2.12.0/contrib/ivshmem-client/main.c 2018-04-24 19:30:46.000000000 +0300
+++ qemu-2.12.0.mod/contrib/ivshmem-client/main.c 2018-06-25 14:12:24.330634752 +0300
@@ -12,7 +12,7 @@
#include "ivshmem-client.h"
#define IVSHMEM_CLIENT_DEFAULT_VERBOSE 0
-#define IVSHMEM_CLIENT_DEFAULT_UNIX_SOCK_PATH "/tmp/ivshmem_socket"
+#define IVSHMEM_CLIENT_DEFAULT_UNIX_SOCK_PATH "@TERMUX_PREFIX@/tmp/ivshmem_socket"
typedef struct IvshmemClientArgs {
bool verbose;

View File

@ -0,0 +1,14 @@
diff -uNr qemu-2.12.0/contrib/ivshmem-server/main.c qemu-2.12.0.mod/contrib/ivshmem-server/main.c
--- qemu-2.12.0/contrib/ivshmem-server/main.c 2018-04-24 19:30:46.000000000 +0300
+++ qemu-2.12.0.mod/contrib/ivshmem-server/main.c 2018-06-25 14:12:36.683968721 +0300
@@ -14,8 +14,8 @@
#define IVSHMEM_SERVER_DEFAULT_VERBOSE 0
#define IVSHMEM_SERVER_DEFAULT_FOREGROUND 0
-#define IVSHMEM_SERVER_DEFAULT_PID_FILE "/var/run/ivshmem-server.pid"
-#define IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH "/tmp/ivshmem_socket"
+#define IVSHMEM_SERVER_DEFAULT_PID_FILE "@TERMUX_PREFIX@/var/run/ivshmem-server.pid"
+#define IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH "@TERMUX_PREFIX@/tmp/ivshmem_socket"
#define IVSHMEM_SERVER_DEFAULT_SHM_PATH "ivshmem"
#define IVSHMEM_SERVER_DEFAULT_SHM_SIZE (4*1024*1024)
#define IVSHMEM_SERVER_DEFAULT_N_VECTORS 1

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/hw/usb/ccid-card-emulated.c qemu-2.12.0.mod/hw/usb/ccid-card-emulated.c
--- qemu-2.12.0/hw/usb/ccid-card-emulated.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/hw/usb/ccid-card-emulated.c 2018-06-25 14:11:33.227298788 +0300
@@ -412,7 +412,7 @@
return 0;
}
-#define CERTIFICATES_DEFAULT_DB "/etc/pki/nssdb"
+#define CERTIFICATES_DEFAULT_DB "@TERMUX_PREFIX@/etc/pki/nssdb"
#define CERTIFICATES_ARGS_TEMPLATE\
"db=\"%s\" use_hw=no soft=(,Virtual Reader,CAC,,%s,%s,%s)"

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/hw/xenpv/xen_domainbuild.c qemu-2.12.0.mod/hw/xenpv/xen_domainbuild.c
--- qemu-2.12.0/hw/xenpv/xen_domainbuild.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/hw/xenpv/xen_domainbuild.c 2018-06-25 14:11:33.227298788 +0300
@@ -166,7 +166,7 @@
/* close all file handles, except stdio/out/err,
* our watch pipe and the xen interface handle */
- n = getdtablesize();
+ n = sysconf(_SC_OPEN_MAX);
for (i = 3; i < n; i++) {
if (i == fd[0])
continue;

View File

@ -0,0 +1,14 @@
diff -uNr qemu-2.12.0/include/net/net.h qemu-2.12.0.mod/include/net/net.h
--- qemu-2.12.0/include/net/net.h 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/include/net/net.h 2018-06-25 14:11:33.230632120 +0300
@@ -217,8 +217,8 @@
int net_hub_id_for_client(NetClientState *nc, int *id);
NetClientState *net_hub_port_find(int hub_id);
-#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
-#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
+#define DEFAULT_NETWORK_SCRIPT "@TERMUX_PREFIX@/etc/qemu-ifup"
+#define DEFAULT_NETWORK_DOWN_SCRIPT "@TERMUX_PREFIX@/etc/qemu-ifdown"
#define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
#define DEFAULT_BRIDGE_INTERFACE "br0"

View File

@ -0,0 +1,48 @@
diff -uNr qemu-2.12.0/linux-user/signal.c qemu-2.12.0.mod/linux-user/signal.c
--- qemu-2.12.0/linux-user/signal.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/linux-user/signal.c 2018-06-25 14:11:33.233965454 +0300
@@ -206,6 +206,26 @@
return atomic_xchg(&ts->signal_pending, 1);
}
+#ifdef _NSIG_WORDS
+static int sigorset(sigset_t *dest, const sigset_t *a, const sigset_t *b)
+{
+ int i;
+ if (!dest || !a || !b)
+ return -1;
+ for (i = 0; i < _NSIG_WORDS; i++)
+ dest->sig[i] = a->sig[i] | b->sig[i];
+ return 0;
+}
+#else
+static int sigorset(sigset_t *dest, const sigset_t *a, const sigset_t *b)
+{
+ int i;
+ if (!dest || !a || !b)
+ return -1;
+ *dest = *a | *b;
+ return 0;
+}
+#endif
/* Wrapper for sigprocmask function
* Emulates a sigprocmask in a safe way for the guest. Note that set and oldset
* are host signal set, not guest ones. Returns -TARGET_ERESTARTSYS if
@@ -1418,7 +1438,7 @@
target_stack_t tuc_stack;
target_sigset_t tuc_sigmask;
/* glibc uses a 1024-bit sigset_t */
- char __unused[1024 / 8 - sizeof(target_sigset_t)];
+ char __qemu_unused[1024 / 8 - sizeof(target_sigset_t)];
/* last for future expansion */
struct target_sigcontext tuc_mcontext;
};
@@ -2004,7 +2024,7 @@
target_stack_t tuc_stack;
struct target_sigcontext tuc_mcontext;
target_sigset_t tuc_sigmask; /* mask last for extensibility */
- char __unused[128 - sizeof(target_sigset_t)];
+ char __qemu_unused[128 - sizeof(target_sigset_t)];
abi_ulong tuc_regspace[128] __attribute__((__aligned__(8)));
};

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/linux-user/strace.c qemu-2.12.0.mod/linux-user/strace.c
--- qemu-2.12.0/linux-user/strace.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/linux-user/strace.c 2018-06-25 14:11:33.243965455 +0300
@@ -1,7 +1,7 @@
#include "qemu/osdep.h"
#include <sys/ipc.h>
#include <sys/msg.h>
-#include <sys/sem.h>
+#include <linux/sem.h>
#include <sys/shm.h>
#include <sys/select.h>
#include <sys/mount.h>

View File

@ -0,0 +1,228 @@
diff -uNr qemu-2.12.0/linux-user/syscall.c qemu-2.12.0.mod/linux-user/syscall.c
--- qemu-2.12.0/linux-user/syscall.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/linux-user/syscall.c 2018-06-25 14:11:33.250632122 +0300
@@ -42,7 +42,7 @@
#include <poll.h>
#include <sys/times.h>
#include <sys/shm.h>
-#include <sys/sem.h>
+#include <linux/sem.h>
#include <sys/statfs.h>
#include <utime.h>
#include <sys/sysinfo.h>
@@ -76,12 +76,16 @@
#endif
#define termios host_termios
+#define termios2 host_termios2
+#define ktermios host_ktermios
#define winsize host_winsize
#define termio host_termio
#define sgttyb host_sgttyb /* same as target */
#define tchars host_tchars /* same as target */
#define ltchars host_ltchars /* same as target */
+#undef __ASM_GENERIC_TERMBITS_H
+#include <asm/termbits.h>
#include <linux/termios.h>
#include <linux/unistd.h>
#include <linux/cdrom.h>
@@ -250,6 +254,64 @@
#define TARGET_NR__llseek TARGET_NR_llseek
#endif
+_syscall0(int, vhangup)
+#ifdef __NR_msgctl
+_syscall3(int, msgctl, int, msqid, int, cmd, struct msqid_ds *, buf)
+#else
+static int
+msgctl (int msqid, int cmd, struct msqid_ds *buf)
+{
+ return syscall (__NR_ipc, IPCOP_msgctl,
+ msqid, cmd | 0x100, 0, buf);
+}
+#endif
+#ifdef __NR_semget
+_syscall3(int, semget, key_t, key, int, nsems, int, semflg)
+#else
+static int
+semget (key_t key,
+ int nsems,
+ int semflg)
+{
+ return syscall (__NR_ipc, IPCOP_semget, key, nsems, semflg, NULL);
+}
+#endif
+_syscall1(int, adjtimex, struct timex *, buf)
+_syscall2(int, sethostname, const char *, name, size_t, len)
+_syscall2(int, setdomainname, const char *, name, size_t, len)
+#ifdef __NR_msgget
+_syscall2(int, msgget, key_t, key, int, msgflg)
+#else
+static int
+msgget (key_t key,
+ int msgflg)
+{
+ return syscall(__NR_ipc, 5, IPCOP_msgget, key, msgflg, 0, NULL);
+}
+#endif
+
+#ifdef _NSIG_WORDS
+static int sigorset(sigset_t *dest, const sigset_t *a, const sigset_t *b)
+{
+ int i;
+ if (!dest || !a || !b)
+ return -1;
+ for (i = 0; i < _NSIG_WORDS; i++)
+ dest->sig[i] = a->sig[i] | b->sig[i];
+ return 0;
+}
+#else
+static int sigorset(sigset_t *dest, const sigset_t *a, const sigset_t *b)
+{
+ int i;
+ if (!dest || !a || !b)
+ return -1;
+ *dest = *a | *b;
+ return 0;
+}
+#endif
+
+#if 0
#ifdef __NR_gettid
_syscall0(int, gettid)
#else
@@ -259,6 +321,7 @@
return -ENOSYS;
}
#endif
+#endif
#if defined(TARGET_NR_getdents) && defined(__NR_getdents)
_syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count);
#endif
@@ -1028,6 +1091,9 @@
size_t, len, unsigned, prio, const struct timespec *, timeout)
safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr,
size_t, len, unsigned *, prio, const struct timespec *, timeout)
+_syscall1(int, mq_unlink, const char *, name)
+_syscall4(__kernel_mqd_t, mq_open, const char *, name, int, oflag, mode_t, mode,
+ struct mq_attr *, attr)
#endif
/* We do ioctl like this rather than via safe_syscall3 to preserve the
* "third argument might be integer or pointer or not present" behaviour of
@@ -1406,7 +1472,7 @@
}
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
-#include <mqueue.h>
+#include <linux/mqueue.h>
static inline abi_long copy_from_user_mq_attr(struct mq_attr *attr,
abi_ulong target_mq_attr_addr)
@@ -4290,6 +4356,8 @@
return 0;
}
+#define semid_ds __kernel_legacy_semid_ds
+
static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd,
abi_ulong target_addr)
{
@@ -4369,6 +4437,16 @@
abi_ulong __buf;
};
+#ifdef __NR_semctl
+_syscall4(int, semctl, int, semid, int, semnum, int, cmd, union semun, arg4)
+#else
+static int semctl(int semid, int semnum, int cmd, union semun arg4)
+{
+ return syscall(__NR_ipc, IPCOP_semctl, semid, semnum, cmd | 0x100,
+ arg4.__buf);
+}
+#endif
+
static inline abi_long target_to_host_semarray(int semid, unsigned short **host_array,
abi_ulong target_addr)
{
@@ -4499,7 +4577,7 @@
case GETPID:
case GETNCNT:
case GETZCNT:
- ret = get_errno(semctl(semid, semnum, cmd, NULL));
+ ret = get_errno(semctl(semid, semnum, cmd, (union semun) {.buf = NULL}));
break;
}
@@ -4581,7 +4659,7 @@
host_md->msg_stime = tswapal(target_md->msg_stime);
host_md->msg_rtime = tswapal(target_md->msg_rtime);
host_md->msg_ctime = tswapal(target_md->msg_ctime);
- host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes);
+ host_md->msg_cbytes = tswapal(target_md->__msg_cbytes);
host_md->msg_qnum = tswapal(target_md->msg_qnum);
host_md->msg_qbytes = tswapal(target_md->msg_qbytes);
host_md->msg_lspid = tswapal(target_md->msg_lspid);
@@ -4602,7 +4680,7 @@
target_md->msg_stime = tswapal(host_md->msg_stime);
target_md->msg_rtime = tswapal(host_md->msg_rtime);
target_md->msg_ctime = tswapal(host_md->msg_ctime);
- target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes);
+ target_md->__msg_cbytes = tswapal(host_md->msg_cbytes);
target_md->msg_qnum = tswapal(host_md->msg_qnum);
target_md->msg_qbytes = tswapal(host_md->msg_qbytes);
target_md->msg_lspid = tswapal(host_md->msg_lspid);
@@ -5673,6 +5751,9 @@
}
#endif
+#undef winsize
+#undef termio
+
static IOCTLEntry ioctl_entries[] = {
#define IOCTL(cmd, access, ...) \
{ TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } },
@@ -7691,7 +7772,7 @@
/* create temporary file to map stat to */
tmpdir = getenv("TMPDIR");
if (!tmpdir)
- tmpdir = "/tmp";
+ tmpdir = "@TERMUX_PREFIX@/tmp";
snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir);
fd = mkstemp(filename);
if (fd < 0) {
@@ -8310,7 +8391,7 @@
unlock_user(p, arg1, 0);
break;
#endif
-#ifdef TARGET_NR_stime /* not on alpha */
+#if 0 // def TARGET_NR_stime /* not on alpha */
case TARGET_NR_stime:
{
time_t host_time;
@@ -8381,7 +8462,7 @@
}
break;
#endif
-#if defined(TARGET_NR_futimesat)
+#if 0 && defined(TARGET_NR_futimesat)
case TARGET_NR_futimesat:
{
struct timeval *tvp, tv[2];
@@ -12125,7 +12206,7 @@
/* Not implemented for now... */
/* case TARGET_NR_mq_notify: */
/* break; */
-
+#if 0
case TARGET_NR_mq_getsetattr:
{
struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
@@ -12143,6 +12224,7 @@
}
break;
#endif
+#endif
#ifdef CONFIG_SPLICE
#ifdef TARGET_NR_tee

View File

@ -0,0 +1,39 @@
diff -uNr qemu-2.12.0/linux-user/syscall_defs.h qemu-2.12.0.mod/linux-user/syscall_defs.h
--- qemu-2.12.0/linux-user/syscall_defs.h 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/linux-user/syscall_defs.h 2018-06-25 14:11:33.257298788 +0300
@@ -1967,7 +1967,7 @@
abi_ulong target_st_mtime_nsec;
abi_ulong target_st_ctime;
abi_ulong target_st_ctime_nsec;
- abi_long __unused[3];
+ abi_long __qemu_unused[3];
};
#elif defined(TARGET_SH4)
@@ -2052,7 +2052,7 @@
abi_ulong target_st_ctime;
abi_ulong target_st_ctime_nsec;
- abi_long __unused[3];
+ abi_long __qemu_unused[3];
};
#elif defined(TARGET_S390X)
struct target_stat {
@@ -2073,7 +2073,7 @@
abi_ulong target_st_ctime_nsec;
abi_ulong st_blksize;
abi_long st_blocks;
- abi_ulong __unused[3];
+ abi_ulong __qemu_unused[3];
};
#elif defined(TARGET_AARCH64)
struct target_stat {
@@ -2095,7 +2095,7 @@
abi_ulong target_st_mtime_nsec;
abi_long target_st_ctime;
abi_ulong target_st_ctime_nsec;
- unsigned int __unused[2];
+ unsigned int __qemu_unused[2];
};
#elif defined(TARGET_XTENSA)
struct target_stat {

View File

@ -0,0 +1,60 @@
diff -uNr qemu-2.12.0/lockf_implementation.h qemu-2.12.0.mod/lockf_implementation.h
--- qemu-2.12.0/lockf_implementation.h 1970-01-01 03:00:00.000000000 +0300
+++ qemu-2.12.0.mod/lockf_implementation.h 2018-06-25 14:11:33.263965456 +0300
@@ -0,0 +1,56 @@
+#ifndef LOCKF_IMPLEMENTATION_H
+#define LOCKF_IMPLEMENTATION_H
+
+//
+// lockf() implementation from GNU Libc
+//
+
+static int lockf (int fd, int cmd, off_t len)
+{
+ struct flock fl;
+
+ memset ((char *) &fl, '\0', sizeof (fl));
+
+ /* lockf is always relative to the current file position. */
+ fl.l_whence = SEEK_CUR;
+ fl.l_start = 0;
+ fl.l_len = len;
+
+ switch (cmd)
+ {
+ case F_TEST:
+ /* Test the lock: return 0 if FD is unlocked or locked by this process;
+ return -1, set errno to EACCES, if another process holds the lock. */
+ fl.l_type = F_RDLCK;
+ if (fcntl (fd, F_GETLK, &fl) < 0)
+ return -1;
+ if (fl.l_type == F_UNLCK || fl.l_pid == getpid ())
+ return 0;
+ errno = EACCES;
+ return -1;
+
+ case F_ULOCK:
+ fl.l_type = F_UNLCK;
+ cmd = F_SETLK;
+ break;
+ case F_LOCK:
+ fl.l_type = F_WRLCK;
+ cmd = F_SETLKW;
+ break;
+ case F_TLOCK:
+ fl.l_type = F_WRLCK;
+ cmd = F_SETLK;
+ break;
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* lockf() is a cancellation point but so is fcntl() if F_SETLKW is
+ used. Therefore we don't have to care about cancellation here,
+ the fcntl() function will take care of it. */
+ return fcntl (fd, cmd, &fl);
+}
+
+#endif

View File

@ -0,0 +1,21 @@
diff -uNr qemu-2.12.0/migration/exec.c qemu-2.12.0.mod/migration/exec.c
--- qemu-2.12.0/migration/exec.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/migration/exec.c 2018-06-25 14:11:33.263965456 +0300
@@ -27,7 +27,7 @@
void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
{
QIOChannel *ioc;
- const char *argv[] = { "/bin/sh", "-c", command, NULL };
+ const char *argv[] = { "@TERMUX_PREFIX@/bin/sh", "-c", command, NULL };
trace_migration_exec_outgoing(command);
ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
@@ -54,7 +54,7 @@
void exec_start_incoming_migration(const char *command, Error **errp)
{
QIOChannel *ioc;
- const char *argv[] = { "/bin/sh", "-c", command, NULL };
+ const char *argv[] = { "@TERMUX_PREFIX@/bin/sh", "-c", command, NULL };
trace_migration_exec_incoming(command);
ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/net/tap.c qemu-2.12.0.mod/net/tap.c
--- qemu-2.12.0/net/tap.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/net/tap.c 2018-06-25 14:11:33.263965456 +0300
@@ -525,7 +525,7 @@
*parg++ = helper_cmd;
*parg++ = NULL;
- execv("/bin/sh", args);
+ execv("@TERMUX_PREFIX@/bin/sh", args);
} else {
/* assume helper is just the executable path name */

View File

@ -0,0 +1,11 @@
diff -uNr qemu-2.12.0/os-posix.c qemu-2.12.0.mod/os-posix.c
--- qemu-2.12.0/os-posix.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/os-posix.c 2018-06-25 14:11:33.267298789 +0300
@@ -36,6 +36,7 @@
#include "qemu/error-report.h"
#include "qemu/log.h"
#include "qemu/cutils.h"
+#include "lockf_implementation.h"
#ifdef CONFIG_LINUX
#include <sys/prctl.h>

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/qemu-nbd.c qemu-2.12.0.mod/qemu-nbd.c
--- qemu-2.12.0/qemu-nbd.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/qemu-nbd.c 2018-06-25 14:13:19.787304273 +0300
@@ -43,7 +43,7 @@
#include "trace/control.h"
#include "qemu-version.h"
-#define SOCKET_PATH "/var/lock/qemu-nbd-%s"
+#define SOCKET_PATH "@TERMUX_PREFIX@/var/lock/qemu-nbd-%s"
#define QEMU_NBD_OPT_CACHE 256
#define QEMU_NBD_OPT_AIO 257
#define QEMU_NBD_OPT_DISCARD 258

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/qga/main.c qemu-2.12.0.mod/qga/main.c
--- qemu-2.12.0/qga/main.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/qga/main.c 2018-06-25 14:11:33.267298789 +0300
@@ -45,6 +45,8 @@
#endif
#endif
+#include "lockf_implementation.h"
+
#ifndef _WIN32
#define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0"
#define QGA_STATE_RELATIVE_DIR "run"

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/roms/openbios/arch/unix/plugins.c qemu-2.12.0.mod/roms/openbios/arch/unix/plugins.c
--- qemu-2.12.0/roms/openbios/arch/unix/plugins.c 2018-04-24 19:33:10.000000000 +0300
+++ qemu-2.12.0.mod/roms/openbios/arch/unix/plugins.c 2018-06-25 14:11:33.270632123 +0300
@@ -14,7 +14,7 @@
#include "unix/plugins.h"
-unsigned char *plugindir = "/usr/share/OpenBIOS/plugins";
+unsigned char *plugindir = "@TERMUX_PREFIX@/share/OpenBIOS/plugins";
#define PLUGINDIR plugindir
#define PATHSIZE 256

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/roms/openbios/arch/unix/plugins/loader.c qemu-2.12.0.mod/roms/openbios/arch/unix/plugins/loader.c
--- qemu-2.12.0/roms/openbios/arch/unix/plugins/loader.c 2018-04-24 19:33:10.000000000 +0300
+++ qemu-2.12.0.mod/roms/openbios/arch/unix/plugins/loader.c 2018-06-25 14:11:33.270632123 +0300
@@ -19,7 +19,7 @@
#include "unix/plugins.h"
-#define PLUGINDIR "/usr/share/OpenBIOS/plugins"
+#define PLUGINDIR "@TERMUX_PREFIX@/share/OpenBIOS/plugins"
#define PATHSIZE 256
#define DEBUG_PLUGINS

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/roms/seabios/scripts/kconfig/lkc.h qemu-2.12.0.mod/roms/seabios/scripts/kconfig/lkc.h
--- qemu-2.12.0/roms/seabios/scripts/kconfig/lkc.h 2018-04-24 19:33:10.000000000 +0300
+++ qemu-2.12.0.mod/roms/seabios/scripts/kconfig/lkc.h 2018-06-25 14:11:33.270632123 +0300
@@ -31,7 +31,7 @@
#define PACKAGE "linux"
#endif
-#define LOCALEDIR "/usr/share/locale"
+#define LOCALEDIR "@TERMUX_PREFIX@/share/locale"
#define _(text) gettext(text)
#define N_(text) (text)

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/roms/skiboot/external/opal-prd/test/test_pnor_ops.c qemu-2.12.0.mod/roms/skiboot/external/opal-prd/test/test_pnor_ops.c
--- qemu-2.12.0/roms/skiboot/external/opal-prd/test/test_pnor_ops.c 2018-04-24 19:33:10.000000000 +0300
+++ qemu-2.12.0.mod/roms/skiboot/external/opal-prd/test/test_pnor_ops.c 2018-06-25 14:11:33.270632123 +0300
@@ -115,7 +115,7 @@
uint8_t data[24];
char filename[24];
- strcpy(filename, "/tmp/pnor-XXXXXX");
+ strcpy(filename, "@TERMUX_PREFIX@/tmp/pnor-XXXXXX");
fd = mkstemp(filename);
if (fd < 0) {

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/scsi/qemu-pr-helper.c qemu-2.12.0.mod/scsi/qemu-pr-helper.c
--- qemu-2.12.0/scsi/qemu-pr-helper.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/scsi/qemu-pr-helper.c 2018-06-25 14:11:33.273965457 +0300
@@ -24,6 +24,8 @@
#include <linux/dm-ioctl.h>
#include <scsi/sg.h>
+#include "lockf_implementation.h"
+
#ifdef CONFIG_LIBCAP
#include <cap-ng.h>
#endif

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/slirp/misc.c qemu-2.12.0.mod/slirp/misc.c
--- qemu-2.12.0/slirp/misc.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/slirp/misc.c 2018-06-25 14:11:33.273965457 +0300
@@ -146,7 +146,7 @@
dup2(s, 0);
dup2(s, 1);
dup2(s, 2);
- for (s = getdtablesize() - 1; s >= 3; s--)
+ for (s = sysconf(_SC_OPEN_MAX) - 1; s >= 3; s--)
close(s);
i = 0;

View File

@ -0,0 +1,21 @@
diff -uNr qemu-2.12.0/slirp/slirp.c qemu-2.12.0.mod/slirp/slirp.c
--- qemu-2.12.0/slirp/slirp.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/slirp/slirp.c 2018-06-25 14:11:33.277298790 +0300
@@ -133,7 +133,7 @@
return 0;
}
old_stat = *cached_stat;
- if (stat("/etc/resolv.conf", cached_stat) != 0) {
+ if (stat("@TERMUX_PREFIX@/etc/resolv.conf", cached_stat) != 0) {
return -1;
}
if (cached_stat->st_dev == old_stat.st_dev
@@ -157,7 +157,7 @@
void *tmp_addr = alloca(addrlen);
unsigned if_index;
- f = fopen("/etc/resolv.conf", "r");
+ f = fopen("@TERMUX_PREFIX@/etc/resolv.conf", "r");
if (!f)
return -1;

View File

@ -0,0 +1,17 @@
diff -uNr qemu-2.12.0/tcg/i386/tcg-target.inc.c qemu-2.12.0.mod/tcg/i386/tcg-target.inc.c
--- qemu-2.12.0/tcg/i386/tcg-target.inc.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/tcg/i386/tcg-target.inc.c 2018-06-25 16:18:25.654357396 +0300
@@ -1869,8 +1869,12 @@
#elif defined(__x86_64__) && defined(__linux__)
# include <asm/prctl.h>
# include <sys/prctl.h>
+# include <linux/unistd.h>
-int arch_prctl(int code, unsigned long addr);
+static int arch_prctl(int code, unsigned long addr)
+{
+ return syscall(__NR_arch_prctl, code, addr);
+}
static int guest_base_flags;
static inline void setup_guest_base_seg(void)

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/tcg/tcg.c qemu-2.12.0.mod/tcg/tcg.c
--- qemu-2.12.0/tcg/tcg.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/tcg/tcg.c 2018-06-25 14:11:33.287298790 +0300
@@ -3717,7 +3717,7 @@
/* Enable this block to be able to debug the ELF image file creation.
One can use readelf, objdump, or other inspection utilities. */
{
- FILE *f = fopen("/tmp/qemu.jit", "w+b");
+ FILE *f = fopen("@TERMUX_PREFIX@/tmp/qemu.jit", "w+b");
if (f) {
if (fwrite(img, img_size, 1, f) != img_size) {
/* Avoid stupid unused return value warning for fwrite. */

View File

@ -0,0 +1,12 @@
diff -uNr qemu-2.12.0/util/qemu-sockets.c qemu-2.12.0.mod/util/qemu-sockets.c
--- qemu-2.12.0/util/qemu-sockets.c 2018-04-24 19:30:47.000000000 +0300
+++ qemu-2.12.0.mod/util/qemu-sockets.c 2018-06-25 14:11:33.290632124 +0300
@@ -841,7 +841,7 @@
path = saddr->path;
} else {
const char *tmpdir = getenv("TMPDIR");
- tmpdir = tmpdir ? tmpdir : "/tmp";
+ tmpdir = tmpdir ? tmpdir : "@TERMUX_PREFIX@/tmp";
path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", tmpdir);
}

View File

@ -0,0 +1,7 @@
TERMUX_SUBPKG_INCLUDE="
bin/qemu-system-aarch64
share/man/man1/qemu-system-aarch64.1
"
TERMUX_SUBPKG_DEPENDS="qemu-system"
TERMUX_SUBPKG_DESCRIPTION="A generic and open source machine emulator and virtualizer (AArch64 target)"

View File

@ -0,0 +1,7 @@
TERMUX_SUBPKG_INCLUDE="
bin/qemu-system-arm
share/man/man1/qemu-system-arm.1
"
TERMUX_SUBPKG_DEPENDS="qemu-system"
TERMUX_SUBPKG_DESCRIPTION="A generic and open source machine emulator and virtualizer (ARM target)"