Skip to content

Commit

Permalink
new package: hangover-libqemu
Browse files Browse the repository at this point in the history
  • Loading branch information
licy183 committed Dec 28, 2023
1 parent 8d85856 commit b875d0d
Show file tree
Hide file tree
Showing 21 changed files with 1,667 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tur-multilib/hangover-libqemu/0000-android-config-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff -uNr qemu-5.2.0/configure qemu-5.2.0.mod/configure
--- qemu-5.2.0/configure 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/configure 2020-12-09 16:24:26.073781672 +0200
@@ -2931,6 +2931,8 @@
fi

has_libgcrypt() {
+ return 0
+
if ! has "libgcrypt-config"
then
return 1
@@ -3000,10 +3002,7 @@
# 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
@@ -4097,6 +4096,7 @@
if compile_prog "" "" ; then
signalfd=yes
fi
+signalfd=no

# check if optreset global is declared by <getopt.h>
optreset="no"
@@ -5973,6 +5973,7 @@
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
@@ -6088,9 +6089,9 @@
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
183 changes: 183 additions & 0 deletions tur-multilib/hangover-libqemu/0001-fix-hardcoded-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
diff -uNr qemu-5.2.0/block.c qemu-5.2.0.mod/block.c
--- qemu-5.2.0/block.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/block.c 2020-12-09 15:25:10.305910980 +0200
@@ -763,7 +763,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-5.2.0/hw/hppa/machine.c qemu-5.2.0.mod/hw/hppa/machine.c
--- qemu-5.2.0/hw/hppa/machine.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/hw/hppa/machine.c 2020-12-09 15:27:27.518908660 +0200
@@ -100,19 +100,19 @@
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, 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 -uNr qemu-5.2.0/hw/usb/ccid-card-emulated.c qemu-5.2.0.mod/hw/usb/ccid-card-emulated.c
--- qemu-5.2.0/hw/usb/ccid-card-emulated.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/hw/usb/ccid-card-emulated.c 2020-12-09 15:28:01.551157409 +0200
@@ -417,7 +417,7 @@
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 -uNr qemu-5.2.0/linux-user/syscall.c qemu-5.2.0.mod/linux-user/syscall.c
--- qemu-5.2.0/linux-user/syscall.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/linux-user/syscall.c 2020-12-09 15:25:10.309911009 +0200
@@ -8045,7 +8045,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-5.2.0/migration/exec.c qemu-5.2.0.mod/migration/exec.c
--- qemu-5.2.0/migration/exec.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/migration/exec.c 2020-12-09 15:25:10.309911009 +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-5.2.0/net/tap.c qemu-5.2.0.mod/net/tap.c
--- qemu-5.2.0/net/tap.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/net/tap.c 2020-12-09 15:25:10.309911009 +0200
@@ -533,7 +533,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 */
diff -uNr qemu-5.2.0/qemu-nbd.c qemu-5.2.0.mod/qemu-nbd.c
--- qemu-5.2.0/qemu-nbd.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/qemu-nbd.c 2020-12-09 15:25:10.313911038 +0200
@@ -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 @@
" -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 @@

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 -uNr qemu-5.2.0/slirp/src/slirp.c qemu-5.2.0.mod/slirp/src/slirp.c
--- qemu-5.2.0/slirp/src/slirp.c 2020-12-08 19:00:58.000000000 +0200
+++ qemu-5.2.0.mod/slirp/src/slirp.c 2020-12-09 15:25:10.313911038 +0200
@@ -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;

diff -uNr qemu-5.2.0/tcg/tcg.c qemu-5.2.0.mod/tcg/tcg.c
--- qemu-5.2.0/tcg/tcg.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/tcg/tcg.c 2020-12-09 15:25:10.313911038 +0200
@@ -4628,7 +4628,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-5.2.0/util/module.c qemu-5.2.0.mod/util/module.c
--- qemu-5.2.0/util/module.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/util/module.c 2020-12-09 15:30:49.368390113 +0200
@@ -246,7 +246,7 @@
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 -uNr qemu-5.2.0/util/qemu-sockets.c qemu-5.2.0.mod/util/qemu-sockets.c
--- qemu-5.2.0/util/qemu-sockets.c 2020-12-08 18:59:44.000000000 +0200
+++ qemu-5.2.0.mod/util/qemu-sockets.c 2020-12-09 15:25:10.313911038 +0200
@@ -900,7 +900,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);
}

12 changes: 12 additions & 0 deletions tur-multilib/hangover-libqemu/0002-fix-soundcard.h-location.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -uNr qemu-4.2.0/audio/ossaudio.c qemu-4.2.0.mod/audio/ossaudio.c
--- qemu-4.2.0/audio/ossaudio.c 2019-12-12 20:20:47.000000000 +0200
+++ qemu-4.2.0.mod/audio/ossaudio.c 2019-12-15 00:04:31.280813450 +0200
@@ -24,7 +24,7 @@

#include "qemu/osdep.h"
#include <sys/ioctl.h>
-#include <sys/soundcard.h>
+#include <linux/soundcard.h>
#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "qemu/host-utils.h"
22 changes: 22 additions & 0 deletions tur-multilib/hangover-libqemu/0003-fix-time_nsec-defs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff -uNr qemu-4.2.0/fsdev/9p-marshal.h qemu-4.2.0.mod/fsdev/9p-marshal.h
--- qemu-4.2.0/fsdev/9p-marshal.h 2019-12-12 20:20:47.000000000 +0200
+++ qemu-4.2.0.mod/fsdev/9p-marshal.h 2019-12-15 00:09:59.586176320 +0200
@@ -48,6 +48,18 @@
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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
diff -uNr qemu-4.2.0/hw/9pfs/9p-local.c qemu-4.2.0.mod/hw/9pfs/9p-local.c
--- qemu-4.2.0/hw/9pfs/9p-local.c 2019-12-12 20:20:47.000000000 +0200
+++ qemu-4.2.0.mod/hw/9pfs/9p-local.c 2019-12-15 00:12:11.073725293 +0200
@@ -535,9 +535,23 @@
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 @@

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 -uNr qemu-4.2.0/hw/9pfs/9p-proxy.c qemu-4.2.0.mod/hw/9pfs/9p-proxy.c
--- qemu-4.2.0/hw/9pfs/9p-proxy.c 2019-12-12 20:20:47.000000000 +0200
+++ qemu-4.2.0.mod/hw/9pfs/9p-proxy.c 2019-12-15 00:12:11.074725297 +0200
@@ -675,9 +675,23 @@
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 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,
31 changes: 31 additions & 0 deletions tur-multilib/hangover-libqemu/0005-add-missing-sigorset.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff -uNr qemu-4.2.0/linux-user/signal.c qemu-4.2.0.mod/linux-user/signal.c
--- qemu-4.2.0/linux-user/signal.c 2019-12-12 20:20:48.000000000 +0200
+++ qemu-4.2.0.mod/linux-user/signal.c 2019-12-15 00:15:27.954549467 +0200
@@ -182,6 +182,27 @@
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
12 changes: 12 additions & 0 deletions tur-multilib/hangover-libqemu/0006-fix-sem.h-location.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -uNr qemu-4.2.0/linux-user/strace.c qemu-4.2.0.mod/linux-user/strace.c
--- qemu-4.2.0/linux-user/strace.c 2019-12-12 20:20:48.000000000 +0200
+++ qemu-4.2.0.mod/linux-user/strace.c 2019-12-15 00:18:22.178280369 +0200
@@ -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>
Loading

0 comments on commit b875d0d

Please sign in to comment.