diff -uNr qemu-4.2.0/block.c qemu-4.2.0.mod/block.c --- qemu-4.2.0/block.c 2019-12-12 20:20:47.000000000 +0200 +++ qemu-4.2.0.mod/block.c 2019-12-14 23:44:51.761245599 +0200 @@ -605,7 +605,7 @@ 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 -uNr qemu-4.2.0/hw/usb/ccid-card-emulated.c qemu-4.2.0.mod/hw/usb/ccid-card-emulated.c --- qemu-4.2.0/hw/usb/ccid-card-emulated.c 2019-12-12 20:20:47.000000000 +0200 +++ qemu-4.2.0.mod/hw/usb/ccid-card-emulated.c 2019-12-14 23:46:14.000525536 +0200 @@ -417,7 +417,6 @@ event_notifier_cleanup(&card->notifier); } -#define CERTIFICATES_DEFAULT_DB "/etc/pki/nssdb" #define CERTIFICATES_ARGS_TEMPLATE\ "db=\"%s\" use_hw=no soft=(,Virtual Reader,CAC,,%s,%s,%s)" @@ -447,7 +446,7 @@ VCardEmulOptions *options = NULL; snprintf(emul_args, sizeof(emul_args) - 1, CERTIFICATES_ARGS_TEMPLATE, - card->db ? card->db : CERTIFICATES_DEFAULT_DB, + card->db ? card->db : "@TERMUX_PREFIX@/etc/pki/nssdb", card->cert1, card->cert2, card->cert3); options = vcard_emul_options(emul_args); if (options == NULL) { diff -uNr qemu-4.2.0/include/net/net.h qemu-4.2.0.mod/include/net/net.h --- qemu-4.2.0/include/net/net.h 2019-12-12 20:20:48.000000000 +0200 +++ qemu-4.2.0.mod/include/net/net.h 2019-12-14 23:41:09.155552313 +0200 @@ -208,8 +208,6 @@ 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_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper" #define DEFAULT_BRIDGE_INTERFACE "br0" diff -uNr qemu-4.2.0/linux-user/syscall.c qemu-4.2.0.mod/linux-user/syscall.c --- qemu-4.2.0/linux-user/syscall.c 2019-12-12 20:20:48.000000000 +0200 +++ qemu-4.2.0.mod/linux-user/syscall.c 2019-12-14 23:41:09.156552316 +0200 @@ -7215,7 +7215,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) { diff -uNr qemu-4.2.0/migration/exec.c qemu-4.2.0.mod/migration/exec.c --- qemu-4.2.0/migration/exec.c 2019-12-12 20:20:48.000000000 +0200 +++ qemu-4.2.0.mod/migration/exec.c 2019-12-14 23:41:09.156552316 +0200 @@ -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 @@ 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 -uNr qemu-4.2.0/net/tap.c qemu-4.2.0.mod/net/tap.c --- qemu-4.2.0/net/tap.c 2019-12-12 20:20:48.000000000 +0200 +++ qemu-4.2.0.mod/net/tap.c 2019-12-14 23:47:32.704802757 +0200 @@ -527,7 +527,7 @@ *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 */ @@ -907,9 +907,9 @@ error_setg(errp, "vhostfds= is invalid if fds= wasn't specified"); return -1; } - script = tap->has_script ? tap->script : DEFAULT_NETWORK_SCRIPT; - downscript = tap->has_downscript ? tap->downscript : - DEFAULT_NETWORK_DOWN_SCRIPT; + + script = tap->has_script ? tap->script : "@TERMUX_PREFIX@/etc/qemu-ifup"; + downscript = tap->has_downscript ? tap->downscript : "@TERMUX_PREFIX@/etc/qemu-ifdown"; if (tap->has_ifname) { pstrcpy(ifname, sizeof ifname, tap->ifname); diff -uNr qemu-4.2.0/qemu-nbd.c qemu-4.2.0.mod/qemu-nbd.c --- qemu-4.2.0/qemu-nbd.c 2019-12-12 20:20:48.000000000 +0200 +++ qemu-4.2.0.mod/qemu-nbd.c 2019-12-14 23:41:09.157552319 +0200 @@ -51,7 +51,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 @@ " -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/qemu-nbd-sock-%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" @@ -1065,7 +1064,7 @@ if (device != NULL && sockpath == NULL) { sockpath = g_malloc(128); - snprintf(sockpath, 128, SOCKET_PATH, basename(device)); + snprintf(sockpath, 128, "@TERMUX_PREFIX@/tmp/qemu-nbd-sock-%s", basename(device)); } server = qio_net_listener_new(); diff -uNr qemu-4.2.0/qemu-options.hx qemu-4.2.0.mod/qemu-options.hx --- qemu-4.2.0/qemu-options.hx 2019-12-12 20:20:48.000000000 +0200 +++ qemu-4.2.0.mod/qemu-options.hx 2019-12-14 23:41:09.158552322 +0200 @@ -2214,8 +2214,8 @@ " [,poll-us=n]\n" " configure a host TAP network backend with ID 'str'\n" " connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n" - " use network scripts 'file' (default=" DEFAULT_NETWORK_SCRIPT ")\n" - " to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n" + " use network scripts 'file' (default=@TERMUX_PREFIX@/etc/qemu-ifup)\n" + " to configure it and 'dfile' (default=@TERMUX_PREFIX@/etc/qemu-ifdown)\n" " to deconfigure it\n" " use '[down]script=no' to disable script execution\n" " use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n" diff -uNr qemu-4.2.0/slirp/src/slirp.c qemu-4.2.0.mod/slirp/src/slirp.c --- qemu-4.2.0/slirp/src/slirp.c 2019-12-12 20:22:51.000000000 +0200 +++ qemu-4.2.0.mod/slirp/src/slirp.c 2019-12-14 23:50:56.864555426 +0200 @@ -128,7 +128,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 && @@ -152,7 +152,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; diff -uNr qemu-4.2.0/tcg/tcg.c qemu-4.2.0.mod/tcg/tcg.c --- qemu-4.2.0/tcg/tcg.c 2019-12-12 20:20:48.000000000 +0200 +++ qemu-4.2.0.mod/tcg/tcg.c 2019-12-14 23:48:54.305098365 +0200 @@ -4530,7 +4530,8 @@ /* 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 -uNr qemu-4.2.0/util/qemu-sockets.c qemu-4.2.0.mod/util/qemu-sockets.c --- qemu-4.2.0/util/qemu-sockets.c 2019-12-12 20:20:48.000000000 +0200 +++ qemu-4.2.0.mod/util/qemu-sockets.c 2019-12-14 23:41:09.158552322 +0200 @@ -877,7 +877,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); }