From c8b24245813ec2860ab6e8361fcef5350a9e8ed3 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 18 Dec 2020 14:24:28 +0300 Subject: [PATCH] apply termux patches --- accel/tcg/translate-all.c | 2 + audio/ossaudio.c | 4 +- block.c | 2 +- block/file-posix.c | 1 + configure | 15 ++-- fsdev/9p-marshal.h | 12 +++ hw/9pfs/9p-local.c | 18 ++++- hw/9pfs/9p-proxy.c | 18 ++++- hw/hppa/machine.c | 8 +- hw/usb/ccid-card-emulated.c | 2 +- hw/vfio/common.c | 1 + hw/vfio/pci-quirks.c | 2 + hw/virtio/vhost-user.c | 1 + include/qapi/util.h | 4 + linux-user/aarch64/signal.c | 2 +- linux-user/arm/signal.c | 2 +- linux-user/elfload.c | 4 +- linux-user/flatload.c | 2 + linux-user/i386/cpu_loop.c | 2 + linux-user/mmap.c | 2 + linux-user/riscv/signal.c | 2 +- linux-user/signal.c | 21 +++++ linux-user/strace.c | 2 +- linux-user/syscall.c | 98 ++++++++++++++++++++--- linux-user/syscall_defs.h | 8 +- meson.build | 14 ++-- migration/exec.c | 4 +- migration/postcopy-ram.c | 2 + net/tap.c | 2 +- qemu-nbd.c | 5 +- softmmu/physmem.c | 2 + subprojects/libvhost-user/libvhost-user.c | 1 + tcg/i386/tcg-target.c.inc | 7 +- tcg/tcg.c | 3 +- tests/meson.build | 1 - tests/vhost-user-bridge.c | 2 + util/drm.c | 1 - util/memfd.c | 1 + util/mmap-alloc.c | 2 +- util/module.c | 2 +- util/oslib-posix.c | 1 + util/qemu-sockets.c | 2 +- util/vfio-helpers.c | 1 + 43 files changed, 231 insertions(+), 57 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b7d50a73d4..e8ed072f23 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -47,6 +47,8 @@ #include "exec/ram_addr.h" #endif +#include + #include "exec/cputlb.h" #include "exec/tb-hash.h" #include "translate-all.h" diff --git a/audio/ossaudio.c b/audio/ossaudio.c index a7dcaa31ad..8646c87236 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -24,13 +24,15 @@ #include "qemu/osdep.h" #include -#include +#include #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/host-utils.h" #include "audio.h" #include "trace.h" +#include + #define AUDIO_CAP "oss" #include "audio_int.h" diff --git a/block.c b/block.c index 8f177504d4..01f0d60762 100644 --- a/block.c +++ b/block.c @@ -764,7 +764,7 @@ int get_tmp_filename(char *filename, int size) const char *tmpdir; tmpdir = getenv("TMPDIR"); if (!tmpdir) { - tmpdir = "/var/tmp"; + tmpdir = "@TERMUX_PREFIX@/tmp"; } if (snprintf(filename, size, "%s/vl.XXXXXX", tmpdir) >= size) { return -EOVERFLOW; diff --git a/block/file-posix.c b/block/file-posix.c index 9804681d5c..be58a7e168 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -59,6 +59,7 @@ #include #endif #ifdef __linux__ +#include #include #include #include diff --git a/configure b/configure index c228f7c21e..f0c58d51b1 100755 --- a/configure +++ b/configure @@ -2939,6 +2939,8 @@ then fi has_libgcrypt() { + return 0 + if ! has "libgcrypt-config" then return 1 @@ -3008,10 +3010,7 @@ if test "$gcrypt" != "no"; then # Debian has removed -lgpg-error from libgcrypt-config # as it "spreads unnecessary dependencies" which in # turn breaks static builds... - if test "$static" = "yes" - then - gcrypt_libs="$gcrypt_libs -lgpg-error" - fi + gcrypt_libs="$gcrypt_libs -lgpg-error" # Link test to make sure the given libraries work (e.g for static). write_c_skeleton @@ -4083,6 +4082,7 @@ EOF if compile_prog "" "" ; then signalfd=yes fi +signalfd=no # check if optreset global is declared by optreset="no" @@ -5947,6 +5947,7 @@ fi if test "$darwin" = "yes" ; then echo "CONFIG_DARWIN=y" >> $config_host_mak fi +ivshmem=no if test "$solaris" = "yes" ; then echo "CONFIG_SOLARIS=y" >> $config_host_mak @@ -6062,9 +6063,9 @@ fi if test "$posix_fallocate" = "yes" ; then echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak fi -if test "$sync_file_range" = "yes" ; then - echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak -fi +#if test "$sync_file_range" = "yes" ; then +# echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak +#fi if test "$fiemap" = "yes" ; then echo "CONFIG_FIEMAP=y" >> $config_host_mak fi diff --git a/fsdev/9p-marshal.h b/fsdev/9p-marshal.h index ceaf2f521e..fa7cd2eb88 100644 --- a/fsdev/9p-marshal.h +++ b/fsdev/9p-marshal.h @@ -44,6 +44,18 @@ typedef struct V9fsIattr { int64_t mtime_nsec; } V9fsIattr; +#ifdef st_atime_nsec +# undef st_atime_nsec +#endif + +#ifdef st_mtime_nsec +# undef st_mtime_nsec +#endif + +#ifdef st_ctime_nsec +# undef st_ctime_nsec +#endif + typedef struct V9fsStatDotl { uint64_t st_result_mask; V9fsQID qid; diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index af52c1daac..b9d9783128 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -535,9 +535,23 @@ static void local_rewinddir(FsContext *ctx, V9fsFidOpenState *fs) rewinddir(fs->dir.stream); } +struct DIR { + int fd_; +}; + +static long android_telldir(struct DIR *dirp) +{ + return (long) lseek(dirp->fd_, 0, SEEK_CUR); +} + +static void android_seekdir(DIR *dirp, long loc) +{ + (void) lseek(dirp->fd_, loc, SEEK_SET); +} + static off_t local_telldir(FsContext *ctx, V9fsFidOpenState *fs) { - return telldir(fs->dir.stream); + return android_telldir(fs->dir.stream); } static bool local_is_mapped_file_metadata(FsContext *fs_ctx, const char *name) @@ -571,7 +585,7 @@ again: static void local_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) { - seekdir(fs->dir.stream, off); + android_seekdir(fs->dir.stream, off); } static ssize_t local_preadv(FsContext *ctx, V9fsFidOpenState *fs, diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index 6f598a0f11..37e0a37caa 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -675,9 +675,23 @@ static void proxy_rewinddir(FsContext *ctx, V9fsFidOpenState *fs) rewinddir(fs->dir.stream); } +struct DIR { + int fd_; +}; + +static long android_telldir(struct DIR *dirp) +{ + return (long) lseek(dirp->fd_, 0, SEEK_CUR); +} + +static void android_seekdir(DIR *dirp, long loc) +{ + (void) lseek(dirp->fd_, loc, SEEK_SET); +} + static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs) { - return telldir(fs->dir.stream); + return android_telldir(fs->dir.stream); } static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs) @@ -687,7 +701,7 @@ static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs) static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) { - seekdir(fs->dir.stream, off); + android_seekdir(fs->dir.stream, off); } static ssize_t proxy_preadv(FsContext *ctx, V9fsFidOpenState *fs, diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index f2b71db9bd..ebef102a3a 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -101,19 +101,19 @@ static FWCfgState *create_fw_cfg(MachineState *ms) fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, ms->ram_size); val = cpu_to_le64(MIN_SEABIOS_HPPA_VERSION); - fw_cfg_add_file(fw_cfg, "/etc/firmware-min-version", + fw_cfg_add_file(fw_cfg, "@TERMUX_PREFIX@/etc/firmware-min-version", g_memdup(&val, sizeof(val)), sizeof(val)); val = cpu_to_le64(HPPA_TLB_ENTRIES); - fw_cfg_add_file(fw_cfg, "/etc/cpu/tlb_entries", + fw_cfg_add_file(fw_cfg, "@TERMUX_PREFIX@/etc/cpu/tlb_entries", g_memdup(&val, sizeof(val)), sizeof(val)); val = cpu_to_le64(HPPA_BTLB_ENTRIES); - fw_cfg_add_file(fw_cfg, "/etc/cpu/btlb_entries", + fw_cfg_add_file(fw_cfg, "@TERMUX_PREFIX@/etc/cpu/btlb_entries", g_memdup(&val, sizeof(val)), sizeof(val)); val = cpu_to_le64(HPA_POWER_BUTTON); - fw_cfg_add_file(fw_cfg, "/etc/power-button-addr", + fw_cfg_add_file(fw_cfg, "@TERMUX_PREFIX@/etc/power-button-addr", g_memdup(&val, sizeof(val)), sizeof(val)); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_order[0]); diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index 2d566f7db1..a8f74471c0 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -417,7 +417,7 @@ static void clean_event_notifier(EmulatedState *card) event_notifier_cleanup(&card->notifier); } -#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)" diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 6ff1daa763..e530fe88a0 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -24,6 +24,7 @@ #include #endif #include +#include #include "hw/vfio/vfio-common.h" #include "hw/vfio/vfio.h" diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 53569925a2..0a4a3c7d0c 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -27,6 +27,8 @@ #include "pci.h" #include "trace.h" +#include + /* * List of device ids/vendor ids for which to disable * option rom loading. This avoids the guest hangs during rom diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 2fdd5daf74..df955188b8 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -32,6 +32,7 @@ #include "standard-headers/linux/vhost_types.h" #ifdef CONFIG_LINUX +#include #include #endif diff --git a/include/qapi/util.h b/include/qapi/util.h index 6178e98e97..82c1852564 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -11,6 +11,10 @@ #ifndef QAPI_UTIL_H #define QAPI_UTIL_H +#include + +typedef struct Error Error; + typedef struct QEnumLookup { const char *const *array; int size; diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index b591790c22..a5bec94cfc 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -38,7 +38,7 @@ struct target_ucontext { 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; }; diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index f21d1535e4..115b78b013 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -59,7 +59,7 @@ struct target_ucontext_v2 { 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))); }; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f15622f93e..3292348949 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2,6 +2,8 @@ #include "qemu/osdep.h" #include +#include + #include #include @@ -2446,7 +2448,7 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr, abi_ulong guest_hiaddr) { /* In order to use host shmat, we must be able to honor SHMLBA. */ - uintptr_t align = MAX(SHMLBA, qemu_host_page_size); + uintptr_t align = MAX(/* SHMLBA */ getpagesize(), qemu_host_page_size); if (have_guest_base) { pgb_have_guest_base(image_name, guest_loaddr, guest_hiaddr, align); diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 14d2999d15..6f04c82a93 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -35,6 +35,8 @@ #include "qemu/osdep.h" +#include + #include "qemu.h" #include "flat.h" #include "target_flat.h" diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c index 70cde417e6..b6898c0ded 100644 --- a/linux-user/i386/cpu_loop.c +++ b/linux-user/i386/cpu_loop.c @@ -22,6 +22,8 @@ #include "qemu.h" #include "cpu_loop-common.h" +#include + /***********************************************************/ /* CPUX86 core interface */ diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 00c05e6a0f..7c68a988f5 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -21,6 +21,8 @@ #include "exec/log.h" #include "qemu.h" +#include + static pthread_mutex_t mmap_mutex = PTHREAD_MUTEX_INITIALIZER; static __thread int mmap_lock_count; diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c index 67a95dbc7b..19697f91ea 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -41,7 +41,7 @@ struct target_ucontext { struct target_ucontext *uc_link; target_stack_t uc_stack; target_sigset_t uc_sigmask; - uint8_t __unused[1024 / 8 - sizeof(target_sigset_t)]; + uint8_t __qemu_unused[1024 / 8 - sizeof(target_sigset_t)]; struct target_sigcontext uc_mcontext QEMU_ALIGNED(16); }; diff --git a/linux-user/signal.c b/linux-user/signal.c index 73de934c65..014404fbeb 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -198,6 +198,27 @@ int block_signals(void) return qatomic_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 diff --git a/linux-user/strace.c b/linux-user/strace.c index e00275fcb5..3a31d79529 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1,7 +1,7 @@ #include "qemu/osdep.h" #include #include -#include +#include #include #include #include diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7bf99beb18..4eea28551e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -78,12 +79,17 @@ #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 + #include #include #include @@ -268,6 +274,59 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR__llseek __NR_lseek #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 + +_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 + /* Newer kernel ports have llseek() instead of _llseek() */ #if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek) #define TARGET_NR__llseek TARGET_NR_llseek @@ -812,6 +871,9 @@ safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, defined(TARGET_NR_mq_timedreceive_time64) 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 @@ -1336,7 +1398,7 @@ static inline abi_long copy_from_user_timezone(struct timezone *tz, #endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) -#include +#include static inline abi_long copy_from_user_mq_attr(struct mq_attr *attr, abi_ulong target_mq_attr_addr) @@ -3871,6 +3933,8 @@ static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr, 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) { @@ -3950,6 +4014,16 @@ union target_semun { 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) { @@ -4080,7 +4154,7 @@ static inline abi_long do_semctl(int semid, int semnum, int cmd, 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; } @@ -4215,7 +4289,7 @@ static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md, 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); @@ -4236,7 +4310,7 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr, 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); @@ -4602,7 +4676,7 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env, abi_ulong mmap_start; /* In order to use the host shmat, we need to honor host SHMLBA. */ - mmap_start = mmap_find_vma(0, shm_info.shm_segsz, MAX(SHMLBA, shmlba)); + mmap_start = mmap_find_vma(0, shm_info.shm_segsz, MAX(/* SHMLBA */ getpagesize(), shmlba)); if (mmap_start == -1) { errno = ENOMEM; @@ -5703,6 +5777,9 @@ static abi_long do_ioctl_drm_i915(const IOCTLEntry *ie, uint8_t *buf_temp, #endif +#undef winsize +#undef termio + IOCTLEntry ioctl_entries[] = { #define IOCTL(cmd, access, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, @@ -8045,7 +8122,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, /* 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) { @@ -8599,7 +8676,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); return ret; #endif -#ifdef TARGET_NR_stime /* not on alpha */ +#if 0 //def TARGET_NR_stime /* not on alpha */ case TARGET_NR_stime: { struct timespec ts; @@ -8663,7 +8740,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif -#if defined(TARGET_NR_futimesat) +#if 0 && defined(TARGET_NR_futimesat) case TARGET_NR_futimesat: { struct timeval *tvp, tv[2]; @@ -12424,7 +12501,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* 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; @@ -12442,6 +12519,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif +#endif #ifdef CONFIG_SPLICE #ifdef TARGET_NR_tee diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index fadd809796..4ecfe8cff8 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1978,7 +1978,7 @@ struct target_stat64 { 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) @@ -2065,7 +2065,7 @@ struct target_stat { 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 { @@ -2086,7 +2086,7 @@ struct target_stat { 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) #define TARGET_STAT_HAVE_NSEC @@ -2109,7 +2109,7 @@ struct target_stat { 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) #define TARGET_STAT_HAVE_NSEC diff --git a/meson.build b/meson.build index 09be385dcd..e39602003d 100644 --- a/meson.build +++ b/meson.build @@ -94,11 +94,11 @@ endif # Specify linker-script with add_project_link_arguments so that it is not placed # within a linker --start-group/--end-group pair -if 'CONFIG_FUZZ' in config_host - add_project_link_arguments(['-Wl,-T,', - (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')], - native: false, language: ['c', 'cpp', 'objc']) -endif +#if 'CONFIG_FUZZ' in config_host +# add_project_link_arguments(['-Wl,-T,', +# (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')], +# native: false, language: ['c', 'cpp', 'objc']) +#endif add_project_arguments(config_host['QEMU_CFLAGS'].split(), native: false, language: ['c', 'objc']) @@ -1612,8 +1612,8 @@ linux_user_ss.add(files('gdbstub.c', 'thunk.c')) specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss) # needed for fuzzing binaries -subdir('tests/qtest/libqos') -subdir('tests/qtest/fuzz') +#subdir('tests/qtest/libqos') +#subdir('tests/qtest/fuzz') ######################## # Library dependencies # diff --git a/migration/exec.c b/migration/exec.c index 375d2e1b54..c3e7254753 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -28,7 +28,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, @@ -55,7 +55,7 @@ static gboolean exec_accept_incoming_migration(QIOChannel *ioc, 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, diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index d99842eb1b..e92d5ae067 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -31,6 +31,8 @@ #include "trace.h" #include "hw/boards.h" +#include + /* Arbitrary limit on size of each discard command, * keeps them around ~200 bytes */ diff --git a/net/tap.c b/net/tap.c index b7512853f4..8d175d6232 100644 --- a/net/tap.c +++ b/net/tap.c @@ -533,7 +533,7 @@ static int net_bridge_run_helper(const char *helper, const char *bridge, *parg++ = helper_cmd; *parg++ = NULL; - execv("/bin/sh", args); + execv("@TERMUX_PREFIX@/bin/sh", args); g_free(helper_cmd); } else { /* assume helper is just the executable path name */ diff --git a/qemu-nbd.c b/qemu-nbd.c index a7075c5419..2b58a453c3 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -52,7 +52,6 @@ #define HAVE_NBD_DEVICE 0 #endif -#define SOCKET_PATH "/var/lock/qemu-nbd-%s" #define QEMU_NBD_OPT_CACHE 256 #define QEMU_NBD_OPT_AIO 257 #define QEMU_NBD_OPT_DISCARD 258 @@ -91,7 +90,7 @@ static void usage(const char *name) " -p, --port=PORT port to listen on (default `%d')\n" " -b, --bind=IFACE interface to bind to (default `0.0.0.0')\n" " -k, --socket=PATH path to the unix socket\n" -" (default '"SOCKET_PATH"')\n" +" (default '@TERMUX_PREFIX@/tmp/nbd-%s')\n" " -e, --shared=NUM device can be shared by NUM clients (default '1')\n" " -t, --persistent don't exit on the last connection\n" " -v, --verbose display extra debugging information\n" @@ -964,7 +963,7 @@ int main(int argc, char **argv) if (device != NULL && sockpath == NULL) { sockpath = g_malloc(128); - snprintf(sockpath, 128, SOCKET_PATH, basename(device)); + snprintf(sockpath, 128, "@TERMUX_PREFIX@/tmp/nbd-%s", basename(device)); } server = qio_net_listener_new(); diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 2cd1de4a2c..a8f9748944 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -17,6 +17,8 @@ * License along with this library; if not, see . */ +#include + #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/error.h" diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index fab7ca17ee..73672a5efc 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -29,6 +29,7 @@ #include #if defined(__linux__) +#include #include #include #include diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index d8797ed398..42cdcdfdbf 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1957,7 +1957,12 @@ static int32_t x86_guest_base_offset; # if defined(__x86_64__) && defined(__linux__) # include # include -int arch_prctl(int code, unsigned long addr); +# include +static int arch_prctl(int code, unsigned long addr) +{ + return syscall(__NR_arch_prctl, code, addr); +} + static inline int setup_guest_base_seg(void) { if (arch_prctl(ARCH_SET_GS, guest_base) == 0) { diff --git a/tcg/tcg.c b/tcg/tcg.c index 43c6cf8f52..cadc715957 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4628,7 +4628,8 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, /* 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. */ diff --git a/tests/meson.build b/tests/meson.build index 1fa068f27b..054a34555d 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -285,5 +285,4 @@ if not get_option('tcg').disabled() endif subdir('qapi-schema') -subdir('qtest') subdir('migration') diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index 24815920b2..8d29879a12 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -29,6 +29,8 @@ #define _FILE_OFFSET_BITS 64 +#include + #include "qemu/osdep.h" #include "qemu/atomic.h" #include "qemu/ctype.h" diff --git a/util/drm.c b/util/drm.c index dae8ffebc8..da630829ac 100644 --- a/util/drm.c +++ b/util/drm.c @@ -17,7 +17,6 @@ #include "qemu/osdep.h" #include "qemu/drm.h" -#include #include int qemu_drm_rendernode_open(const char *rendernode) diff --git a/util/memfd.c b/util/memfd.c index 4a3c07e0be..03996f18ed 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -32,6 +32,7 @@ #include "qemu/host-utils.h" #if defined CONFIG_LINUX && !defined CONFIG_MEMFD +#include #include #include diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 27dcccd8ec..f0f6b0db92 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -10,7 +10,7 @@ * later. See the COPYING file in the top-level directory. */ -#ifdef CONFIG_LINUX +#ifdef __linux__ #include #else /* !CONFIG_LINUX */ #define MAP_SYNC 0x0 diff --git a/util/module.c b/util/module.c index c65060c167..3cdf09f2ab 100644 --- a/util/module.c +++ b/util/module.c @@ -246,7 +246,7 @@ bool module_load_one(const char *prefix, const char *lib_name, bool mayfail) version_dir = g_strcanon(g_strdup(QEMU_PKGVERSION), G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "+-.~", '_'); - dirs[n_dirs++] = g_strdup_printf("/var/run/qemu/%s", version_dir); + dirs[n_dirs++] = g_strdup_printf("@TERMUX_PREFIX@/var/run/qemu/%s", version_dir); #endif assert(n_dirs <= ARRAY_SIZE(dirs)); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index f15234b5c0..1cd2bee56a 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -41,6 +41,7 @@ #include "qemu/cutils.h" #ifdef CONFIG_LINUX +#include #include #endif diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 8af0278f15..9dee9a86ed 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -900,7 +900,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, 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); } diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 97dfa3fd57..3a8f6dccbf 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include #include +#include #include "qapi/error.h" #include "exec/ramlist.h" #include "exec/cpu-common.h"