diff options
author | Björn Bidar | 2022-05-22 01:55:23 +0300 |
---|---|---|
committer | Björn Bidar | 2022-05-22 02:05:43 +0300 |
commit | f40700bca140aab1918188ccc2c2d6dcdd3b91fa (patch) | |
tree | ee659257ca8e495b51830bb6f0ecbd50a2bc9f3d | |
download | aur-f40700bca140aab1918188ccc2c2d6dcdd3b91fa.tar.gz |
Added as 7.0.0-1
- Initial packaging for qemu patched for use with scratchbox2
-rw-r--r-- | .SRCINFO | 117 | ||||
-rw-r--r-- | 0001-Revert-linux-user-Use-safe_syscall-for-open-and-open.patch | 61 | ||||
-rw-r--r-- | 0002-Revert-linux-user-Use-safe_syscall-for-execve-syscal.patch | 41 | ||||
-rw-r--r-- | 0003-Revert-linux-user-Use-safe_syscall-wrapper-for-send-.patch | 78 | ||||
-rw-r--r-- | 0004-Revert-linux-user-Use-safe_syscall-wrapper-for-accep.patch | 62 | ||||
-rw-r--r-- | 0005-Revert-linux-user-Use-safe_syscall-wrapper-for-conne.patch | 24 | ||||
-rw-r--r-- | 0006-Revert-linux-user-Use-direct-syscall-for-utimensat.patch | 41 | ||||
-rw-r--r-- | 0007-Revert-util-drop-old-utimensat-compat-code.patch | 165 | ||||
-rw-r--r-- | 0008-Revert-linux-user-Use-safe_syscall-wrapper-for-fcntl.patch | 144 | ||||
-rw-r--r-- | 0009-make-sure-mode-is-passed-to-openat-if-O_TMPFILE-is-s.patch | 23 | ||||
-rw-r--r-- | 0010-linux-user-disable-commpage.patch | 33 | ||||
-rw-r--r-- | 0011-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch | 89 | ||||
-rw-r--r-- | 0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch | 106 | ||||
-rw-r--r-- | PKGBUILD | 272 |
14 files changed, 1256 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..bc1f96afd8f4 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,117 @@ +# Generated by mksrcinfo v8 +# Sat May 21 22:54:09 UTC 2022 +pkgbase = qemu-scratchbox2 + pkgdesc = A generic and open source machine emulator and virtualizer patched for use with scratchbox2 + pkgver = 7.0.0 + pkgrel = 10 + url = https://www.qemu.org/ + arch = x86_64 + license = GPL2 + license = LGPL2.1 + makedepends = alsa-lib + makedepends = brltty + makedepends = bzip2 + makedepends = cairo + makedepends = ceph + makedepends = curl + makedepends = dtc + makedepends = fuse3 + makedepends = gcc-libs + makedepends = gdk-pixbuf2 + makedepends = glib2 + makedepends = glusterfs + makedepends = gnutls + makedepends = gtk3 + makedepends = jack + makedepends = libaio + makedepends = libbpf + makedepends = libcacard + makedepends = libcap-ng + makedepends = libepoxy + makedepends = libiscsi + makedepends = libnfs + makedepends = libpng + makedepends = libpulse + makedepends = libsasl + makedepends = libseccomp + makedepends = libslirp + makedepends = libssh + makedepends = liburing + makedepends = libusb + makedepends = libx11 + makedepends = libxml2 + makedepends = libxkbcommon + makedepends = lzo + makedepends = mesa + makedepends = meson + makedepends = multipath-tools + makedepends = ncurses + makedepends = ndctl + makedepends = numactl + makedepends = pam + makedepends = python + makedepends = python-sphinx + makedepends = python-sphinx_rtd_theme + makedepends = sdl2 + makedepends = sdl2_image + makedepends = snappy + makedepends = spice-protocol + makedepends = spice + makedepends = systemd + makedepends = usbredir + makedepends = vde2 + makedepends = virglrenderer + makedepends = vte3 + makedepends = zlib + makedepends = zstd + options = debug + source = https://download.qemu.org/qemu-7.0.0.tar.xz + source = https://download.qemu.org/qemu-7.0.0.tar.xz.sig + source = 0001-Revert-linux-user-Use-safe_syscall-for-open-and-open.patch + source = 0002-Revert-linux-user-Use-safe_syscall-for-execve-syscal.patch + source = 0003-Revert-linux-user-Use-safe_syscall-wrapper-for-send-.patch + source = 0004-Revert-linux-user-Use-safe_syscall-wrapper-for-accep.patch + source = 0005-Revert-linux-user-Use-safe_syscall-wrapper-for-conne.patch + source = 0006-Revert-linux-user-Use-direct-syscall-for-utimensat.patch + source = 0007-Revert-util-drop-old-utimensat-compat-code.patch + source = 0008-Revert-linux-user-Use-safe_syscall-wrapper-for-fcntl.patch + source = 0009-make-sure-mode-is-passed-to-openat-if-O_TMPFILE-is-s.patch + source = 0010-linux-user-disable-commpage.patch + source = 0011-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch + source = 0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch + sha512sums = 44ecd10c018a3763e1bc87d1d35b98890d0d5636acd69fe9b5cadf5024d5af6a31684d60cbe1c3370e02986434c1fb0ad99224e0e6f6fe7eda169992508157b1 + sha512sums = SKIP + sha512sums = b8f16f8e73a05aba0caab7844700ee57dcd9aba337a58a5a6b862ac4642919378ca9532972b760b42a65f48730ab96a4c5e4bd68af7f42b0e18a5e050a68539d + sha512sums = 124b4be68e3949293c0c90cee8c6da719c871426e83fbc9e52597d02dfaf79ce95ed12373e3d0bafbd83f019fd6e254ec91651dab17a868c06b7eaa8abc1e19a + sha512sums = 37626ac06af37a324f4912dff689b52a9b3da27e08a0029ad2dd0855137fae8b3aacb873456897298f9a4fb28e4f04929477ab433ede0e6e9cb3534657114233 + sha512sums = b173e735ce7f81c4ad986d8b6d774663957e59ee025cd153f6b016c5687a7d62a82b031e5956dd7b8ecf086addc38b1a509d7c3180988bdd7333847557781c9f + sha512sums = 520697682261e89017b091f3ce16a1bab8be18d2291a9febf9eb7ed8e1a54422eb3a26e96f16d8994d50ca73f6e08f3df7dc5130fadffe5cf9c52c779d501c51 + sha512sums = c0c74faab1685107b0e83e76e5a592966d3e3497191cf32b3d84fff70feac1ebdbcf3d8a481fdddfd04d79883e3155db9564c9a51b279a83cf650b248d76b033 + sha512sums = 6fb03b29ea9a3c2ab13da01d97c735b2b28dbe262cd18f068f21ce5b808cab0042c2f22b5066da744255ac380104b8740d02754fe11c3e4f0e864bbf6e46336a + sha512sums = 9db86e41e7725fd670625b78341a4b5c20e8271b4ab2673cda153696cb57f662bd5383f96c887a41a629cf8c35ed36f6a20f8b8bec23ab7cbf3621695ff7d697 + sha512sums = ef057bf82dd81bbf4fd1270876698efc69e5f9c4f34c4b424e6562eeed64a8fa70126b192c041d342e7b44369223d79b587198a2a07d0cef16c03305a75d7b00 + sha512sums = 57f4b72df80333e457bbc6a9afa47af40dcd59a32d55a7babda5b5378f9485282823c50e2baca54230fc77056303e809b2108b9ffb73d64eab7eedbf67303ab5 + sha512sums = 4c66df5ffbae302bf0a2f5f6aab1536ac00b5e57eab94e69f7fbd79f54fefa47c46ca20c3b039fd7e51ee72bc74142ab7a94ec2e64f653682992a7df30867d9b + sha512sums = 155b3de89a18fa8cb234ce71767dbf59ab4e0ed2c6375279413fa2c11c128d46bdc2c28467fdbe226e2188755cecae2e33c964f7a35806882a173551d9765684 + +pkgname = qemu-scratchbox2-tests + pkgdesc = QEMU tests patched for use with scratchbox2 + depends = qemu-common + provides = qemu-tests + conflicts = qemu-tests + +pkgname = qemu-scratchbox2-user + pkgdesc = QEMU user mode emulation patched for use with scratchbox2 + depends = gcc-libs + depends = glib2 + depends = libglib-2.0.so + depends = libgmodule-2.0.so + depends = glibc + depends = gnutls + depends = liburing + depends = liburing.so + depends = qemu-common + depends = zlib + provides = qemu-user + conflicts = qemu-user + diff --git a/0001-Revert-linux-user-Use-safe_syscall-for-open-and-open.patch b/0001-Revert-linux-user-Use-safe_syscall-for-open-and-open.patch new file mode 100644 index 000000000000..b051b49b3762 --- /dev/null +++ b/0001-Revert-linux-user-Use-safe_syscall-for-open-and-open.patch @@ -0,0 +1,61 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 22 Jan 2020 10:47:20 +0200 +Subject: [PATCH] Revert "linux-user: Use safe_syscall for open and openat + system calls" + +This reverts commit c10a07387b77b94d8f7233f3b5bb559211d4e49a. +--- + linux-user/syscall.c | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index f65045efe6a22bb38d0c95dde0844345795cf188..9ed3e732cd7444cf18a951677663cc5f45acffde 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -439,6 +439,18 @@ static const bitmask_transtbl fcntl_flags_tbl[] = { + + _syscall2(int, sys_getcwd1, char *, buf, size_t, size) + ++static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) ++{ ++ /* ++ * open(2) has extra parameter 'mode' when called with ++ * flag O_CREAT. ++ */ ++ if ((flags & O_CREAT) != 0) { ++ return (openat(dirfd, pathname, flags, mode)); ++ } ++ return (openat(dirfd, pathname, flags)); ++} ++ + #if defined(TARGET_NR_utimensat) || defined(TARGET_NR_utimensat_time64) + #if defined(__NR_utimensat) + #define __NR_sys_utimensat __NR_utimensat +@@ -625,8 +637,6 @@ static type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + + safe_syscall3(ssize_t, read, int, fd, void *, buff, size_t, count) + safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count) +-safe_syscall4(int, openat, int, dirfd, const char *, pathname, \ +- int, flags, mode_t, mode) + #if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid) + safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \ + struct rusage *, rusage) +@@ -8240,7 +8250,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, + + if (is_proc_myself(pathname, "exe")) { + int execfd = qemu_getauxval(AT_EXECFD); +- return execfd ? execfd : safe_openat(dirfd, exec_path, flags, mode); ++ return execfd ? execfd : sys_openat(dirfd, exec_path, flags, mode); + } + + for (fake_open = fakes; fake_open->filename; fake_open++) { +@@ -8276,7 +8286,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, + return fd; + } + +- return safe_openat(dirfd, path(pathname), flags, mode); ++ return sys_openat(dirfd, path(pathname), flags, mode); + } + + #define TIMER_MAGIC 0x0caf0000 diff --git a/0002-Revert-linux-user-Use-safe_syscall-for-execve-syscal.patch b/0002-Revert-linux-user-Use-safe_syscall-for-execve-syscal.patch new file mode 100644 index 000000000000..86252bf71eaf --- /dev/null +++ b/0002-Revert-linux-user-Use-safe_syscall-for-execve-syscal.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 22 Jan 2020 10:48:18 +0200 +Subject: [PATCH] Revert "linux-user: Use safe_syscall for execve syscall" + +This reverts commit ffdcbe223d23461669869e85786145cce65e1e8c. +--- + linux-user/syscall.c | 13 +------------ + 1 file changed, 1 insertion(+), 12 deletions(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index 9ed3e732cd7444cf18a951677663cc5f45acffde..56310dd38dcffba5b846e36af03e6beb5dd006eb 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -643,7 +643,6 @@ safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \ + #endif + safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \ + int, options, struct rusage *, rusage) +-safe_syscall3(int, execve, const char *, filename, char **, argv, char **, envp) + #if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) || \ + defined(TARGET_NR_pselect6) || defined(TARGET_NR_pselect6_time64) + safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, \ +@@ -8813,17 +8812,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, + + if (!(p = lock_user_string(arg1))) + goto execve_efault; +- /* Although execve() is not an interruptible syscall it is +- * a special case where we must use the safe_syscall wrapper: +- * if we allow a signal to happen before we make the host +- * syscall then we will 'lose' it, because at the point of +- * execve the process leaves QEMU's control. So we use the +- * safe syscall wrapper to ensure that we either take the +- * signal as a guest signal, or else it does not happen +- * before the execve completes and makes it the other +- * program's problem. +- */ +- ret = get_errno(safe_execve(p, argp, envp)); ++ ret = get_errno(execve(p, argp, envp)); + unlock_user(p, arg1, 0); + + goto execve_end; diff --git a/0003-Revert-linux-user-Use-safe_syscall-wrapper-for-send-.patch b/0003-Revert-linux-user-Use-safe_syscall-wrapper-for-send-.patch new file mode 100644 index 000000000000..70cf1ddca2f8 --- /dev/null +++ b/0003-Revert-linux-user-Use-safe_syscall-wrapper-for-send-.patch @@ -0,0 +1,78 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 22 Jan 2020 10:57:53 +0200 +Subject: [PATCH] Revert "linux-user: Use safe_syscall wrapper for send* and + recv* syscalls" + +This reverts commit 666875306e03e1f94e1d4c808502585c10abc69a. +--- + linux-user/syscall.c | 22 +++++++--------------- + 1 file changed, 7 insertions(+), 15 deletions(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index 56310dd38dcffba5b846e36af03e6beb5dd006eb..af8ce5b4bd67490459dfcf12e28e3a42eb5771cd 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -674,14 +674,6 @@ safe_syscall5(ssize_t, preadv, int, fd, const struct iovec *, iov, int, iovcnt, + unsigned long, pos_l, unsigned long, pos_h) + safe_syscall5(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, iovcnt, + unsigned long, pos_l, unsigned long, pos_h) +-safe_syscall3(int, connect, int, fd, const struct sockaddr *, addr, +- socklen_t, addrlen) +-safe_syscall6(ssize_t, sendto, int, fd, const void *, buf, size_t, len, +- int, flags, const struct sockaddr *, addr, socklen_t, addrlen) +-safe_syscall6(ssize_t, recvfrom, int, fd, void *, buf, size_t, len, +- int, flags, struct sockaddr *, addr, socklen_t *, addrlen) +-safe_syscall3(ssize_t, sendmsg, int, fd, const struct msghdr *, msg, int, flags) +-safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags) + safe_syscall2(int, flock, int, fd, int, operation) + #if defined(TARGET_NR_rt_sigtimedwait) || defined(TARGET_NR_rt_sigtimedwait_time64) + safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *, uinfo, +@@ -3290,17 +3282,17 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, + msg.msg_iov->iov_len); + if (ret >= 0) { + msg.msg_iov->iov_base = host_msg; +- ret = get_errno(safe_sendmsg(fd, &msg, flags)); ++ ret = get_errno(sendmsg(fd, &msg, flags)); + } + g_free(host_msg); + } else { + ret = target_to_host_cmsg(&msg, msgp); + if (ret == 0) { +- ret = get_errno(safe_sendmsg(fd, &msg, flags)); ++ ret = get_errno(sendmsg(fd, &msg, flags)); + } + } + } else { +- ret = get_errno(safe_recvmsg(fd, &msg, flags)); ++ ret = get_errno(recvmsg(fd, &msg, flags)); + if (!is_error(ret)) { + len = ret; + if (fd_trans_host_to_target_data(fd)) { +@@ -3548,9 +3540,9 @@ static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags, + if (ret) { + goto fail; + } +- ret = get_errno(safe_sendto(fd, host_msg, len, flags, addr, addrlen)); ++ ret = get_errno(sendto(fd, host_msg, len, flags, addr, addrlen)); + } else { +- ret = get_errno(safe_sendto(fd, host_msg, len, flags, NULL, 0)); ++ ret = get_errno(send(fd, host_msg, len, flags)); + } + fail: + if (copy_msg) { +@@ -3590,12 +3582,12 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags, + } + addr = alloca(addrlen); + ret_addrlen = addrlen; +- ret = get_errno(safe_recvfrom(fd, host_msg, len, flags, ++ ret = get_errno(recvfrom(fd, host_msg, len, flags, + addr, &ret_addrlen)); + } else { + addr = NULL; /* To keep compiler quiet. */ + addrlen = 0; /* To keep compiler quiet. */ +- ret = get_errno(safe_recvfrom(fd, host_msg, len, flags, NULL, 0)); ++ ret = get_errno(recvfrom(fd, host_msg, len, flags, NULL, 0)); + } + if (!is_error(ret)) { + if (fd_trans_host_to_target_data(fd)) { diff --git a/0004-Revert-linux-user-Use-safe_syscall-wrapper-for-accep.patch b/0004-Revert-linux-user-Use-safe_syscall-wrapper-for-accep.patch new file mode 100644 index 000000000000..4e51ce120aaa --- /dev/null +++ b/0004-Revert-linux-user-Use-safe_syscall-wrapper-for-accep.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 22 Jan 2020 10:59:47 +0200 +Subject: [PATCH] Revert "linux-user: Use safe_syscall wrapper for accept and + accept4 syscalls" + +This reverts commit ff6dc130794bcd5b2033bc50262a7720285a74c7. +--- + linux-user/syscall.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index af8ce5b4bd67490459dfcf12e28e3a42eb5771cd..07daa16985ad75564a4d78c0e73d4720b71473f3 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -679,8 +679,6 @@ safe_syscall2(int, flock, int, fd, int, operation) + safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *, uinfo, + const struct timespec *, uts, size_t, sigsetsize) + #endif +-safe_syscall4(int, accept4, int, fd, struct sockaddr *, addr, socklen_t *, len, +- int, flags) + #if defined(TARGET_NR_nanosleep) + safe_syscall2(int, nanosleep, const struct timespec *, req, + struct timespec *, rem) +@@ -3387,6 +3385,19 @@ static abi_long do_sendrecvmmsg(int fd, abi_ulong target_msgvec, + return ret; + } + ++/* If we don't have a system accept4() then just call accept. ++ * The callsites to do_accept4() will ensure that they don't ++ * pass a non-zero flags argument in this config. ++ */ ++#ifndef CONFIG_ACCEPT4 ++static inline int accept4(int sockfd, struct sockaddr *addr, ++ socklen_t *addrlen, int flags) ++{ ++ assert(flags == 0); ++ return accept(sockfd, addr, addrlen); ++} ++#endif ++ + /* do_accept4() Must return target values and target errnos. */ + static abi_long do_accept4(int fd, abi_ulong target_addr, + abi_ulong target_addrlen_addr, int flags) +@@ -3399,7 +3410,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr, + host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl); + + if (target_addr == 0) { +- return get_errno(safe_accept4(fd, NULL, NULL, host_flags)); ++ return get_errno(accept4(fd, NULL, NULL, host_flags)); + } + + /* linux returns EFAULT if addrlen pointer is invalid */ +@@ -3417,7 +3428,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr, + addr = alloca(addrlen); + + ret_addrlen = addrlen; +- ret = get_errno(safe_accept4(fd, addr, &ret_addrlen, host_flags)); ++ ret = get_errno(accept4(fd, addr, &ret_addrlen, host_flags)); + if (!is_error(ret)) { + host_to_target_sockaddr(target_addr, addr, MIN(addrlen, ret_addrlen)); + if (put_user_u32(ret_addrlen, target_addrlen_addr)) { diff --git a/0005-Revert-linux-user-Use-safe_syscall-wrapper-for-conne.patch b/0005-Revert-linux-user-Use-safe_syscall-wrapper-for-conne.patch new file mode 100644 index 000000000000..00ffa4bb31a7 --- /dev/null +++ b/0005-Revert-linux-user-Use-safe_syscall-wrapper-for-conne.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 22 Jan 2020 11:13:13 +0200 +Subject: [PATCH] Revert "linux-user: Use safe_syscall wrapper for connect + syscall" + +This reverts commit 2a3c7619288af9cfcc09a233dce911bf80849dfb. +--- + linux-user/syscall.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index 07daa16985ad75564a4d78c0e73d4720b71473f3..b894acd0d7b3c258bf41272e5600ed69673b35ed 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -3211,7 +3211,7 @@ static abi_long do_connect(int sockfd, abi_ulong target_addr, + if (ret) + return ret; + +- return get_errno(safe_connect(sockfd, addr, addrlen)); ++ return get_errno(connect(sockfd, addr, addrlen)); + } + + /* do_sendrecvmsg_locked() Must return target values and target errnos. */ diff --git a/0006-Revert-linux-user-Use-direct-syscall-for-utimensat.patch b/0006-Revert-linux-user-Use-direct-syscall-for-utimensat.patch new file mode 100644 index 000000000000..fc91eca47865 --- /dev/null +++ b/0006-Revert-linux-user-Use-direct-syscall-for-utimensat.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 29 Jan 2020 12:49:43 +0200 +Subject: [PATCH] Revert "linux-user: Use direct syscall for utimensat" + +This reverts commit 700fa58e4b9100d6bd77df06d2e5d1f457720c4d. +--- + linux-user/syscall.c | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index b894acd0d7b3c258bf41272e5600ed69673b35ed..925c6111a59832300dd1fc93cef06e7bedce5c64 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -452,17 +452,19 @@ static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) + } + + #if defined(TARGET_NR_utimensat) || defined(TARGET_NR_utimensat_time64) +-#if defined(__NR_utimensat) +-#define __NR_sys_utimensat __NR_utimensat +-_syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, +- const struct timespec *,tsp,int,flags) +-#else ++#ifdef CONFIG_UTIMENSAT + static int sys_utimensat(int dirfd, const char *pathname, + const struct timespec times[2], int flags) + { +- errno = ENOSYS; +- return -1; ++ if (pathname == NULL) ++ return futimens(dirfd, times); ++ else ++ return utimensat(dirfd, pathname, times, flags); + } ++#elif defined(__NR_utimensat) ++#define __NR_sys_utimensat __NR_utimensat ++_syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, ++ const struct timespec *,tsp,int,flags) + #endif + #endif /* TARGET_NR_utimensat */ + diff --git a/0007-Revert-util-drop-old-utimensat-compat-code.patch b/0007-Revert-util-drop-old-utimensat-compat-code.patch new file mode 100644 index 000000000000..04fd236ed420 --- /dev/null +++ b/0007-Revert-util-drop-old-utimensat-compat-code.patch @@ -0,0 +1,165 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 29 Jan 2020 11:21:54 +0000 +Subject: [PATCH] Revert "util: drop old utimensat() compat code" + +This reverts commit fcdcf1eed2fd26bfe836080755ba4322d3c1f2cc. + +Conflicts: + slirp +--- + configure | 52 +++++++++++++++++++++++++++++++++++++++ + include/sysemu/os-posix.h | 11 +++++++++ + util/oslib-posix.c | 47 +++++++++++++++++++++++++++++++++++ + 3 files changed, 110 insertions(+) + +diff --git a/configure b/configure +index 7c08c18358becf49779c876b0f3d17329df053c6..7a45cb3f87367a1d7d5149e143fe54b9787b6de0 100755 +--- a/configure ++++ b/configure +@@ -2312,6 +2312,55 @@ EOF + fi + fi + ++# check if utimensat and futimens are supported ++utimens=no ++cat > $TMPC << EOF ++#define _ATFILE_SOURCE ++#include <stddef.h> ++#include <fcntl.h> ++#include <sys/stat.h> ++ ++int main(void) ++{ ++ utimensat(AT_FDCWD, "foo", NULL, 0); ++ futimens(0, NULL); ++ return 0; ++} ++EOF ++if compile_prog "" "" ; then ++ utimens=yes ++fi ++ ++########################################## ++# libnuma probe ++ ++if test "$numa" != "no" ; then ++ cat > $TMPC << EOF ++#include <numa.h> ++int main(void) { return numa_available(); } ++EOF ++ ++ if compile_prog "" "-lnuma" ; then ++ numa=yes ++ numa_libs="-lnuma" ++ else ++ if test "$numa" = "yes" ; then ++ feature_not_found "numa" "install numactl devel" ++ fi ++ numa=no ++ fi ++fi ++ ++malloc=system ++if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then ++ echo "ERROR: tcmalloc && jemalloc can't be used at the same time" ++ exit 1 ++elif test "$tcmalloc" = "yes" ; then ++ malloc=tcmalloc ++elif test "$jemalloc" = "yes" ; then ++ malloc=jemalloc ++fi ++ + # check for usbfs + have_usbfs=no + if test "$linux_user" = "yes"; then +@@ -2829,6 +2878,9 @@ fi + if test "$module_upgrades" = "yes"; then + echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak + fi ++if test "$utimens" = "yes" ; then ++ echo "CONFIG_UTIMENSAT=y" >> $config_host_mak ++fi + if test "$have_usbfs" = "yes" ; then + echo "CONFIG_USBFS=y" >> $config_host_mak + fi +diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h +index dd64fb401dfb8b7ffcaf6013ef3316a74b4d3c0d..f99c812f6c456fc40ed4bdaaac0b5ffc93642b86 100644 +--- a/include/sysemu/os-posix.h ++++ b/include/sysemu/os-posix.h +@@ -56,6 +56,17 @@ typedef struct timeval qemu_timeval; + #define qemu_gettimeofday(tp) gettimeofday(tp, NULL) + + int os_set_daemonize(bool d); ++#ifndef CONFIG_UTIMENSAT ++#ifndef UTIME_NOW ++# define UTIME_NOW ((1l << 30) - 1l) ++#endif ++#ifndef UTIME_OMIT ++# define UTIME_OMIT ((1l << 30) - 2l) ++#endif ++#endif ++typedef struct timespec qemu_timespec; ++int qemu_utimens(const char *path, const qemu_timespec *times); ++ + bool is_daemonized(void); + + /** +diff --git a/util/oslib-posix.c b/util/oslib-posix.c +index 2ebfb7505787ec342773b12999ea85fd13c81040..6ff0d50d8c1d6bb95a31201a776c095b7f52797a 100644 +--- a/util/oslib-posix.c ++++ b/util/oslib-posix.c +@@ -298,6 +298,53 @@ int qemu_pipe(int pipefd[2]) + return ret; + } + ++int qemu_utimens(const char *path, const struct timespec *times) ++{ ++ struct timeval tv[2], tv_now; ++ struct stat st; ++ int i; ++#ifdef CONFIG_UTIMENSAT ++ int ret; ++ ++ ret = utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW); ++ if (ret != -1 || errno != ENOSYS) { ++ return ret; ++ } ++#endif ++ /* Fallback: use utimes() instead of utimensat() */ ++ ++ /* happy if special cases */ ++ if (times[0].tv_nsec == UTIME_OMIT && times[1].tv_nsec == UTIME_OMIT) { ++ return 0; ++ } ++ if (times[0].tv_nsec == UTIME_NOW && times[1].tv_nsec == UTIME_NOW) { ++ return utimes(path, NULL); ++ } ++ ++ /* prepare for hard cases */ ++ if (times[0].tv_nsec == UTIME_NOW || times[1].tv_nsec == UTIME_NOW) { ++ gettimeofday(&tv_now, NULL); ++ } ++ if (times[0].tv_nsec == UTIME_OMIT || times[1].tv_nsec == UTIME_OMIT) { ++ stat(path, &st); ++ } ++ ++ for (i = 0; i < 2; i++) { ++ if (times[i].tv_nsec == UTIME_NOW) { ++ tv[i].tv_sec = tv_now.tv_sec; ++ tv[i].tv_usec = tv_now.tv_usec; ++ } else if (times[i].tv_nsec == UTIME_OMIT) { ++ tv[i].tv_sec = (i == 0) ? st.st_atime : st.st_mtime; ++ tv[i].tv_usec = 0; ++ } else { ++ tv[i].tv_sec = times[i].tv_sec; ++ tv[i].tv_usec = times[i].tv_nsec / 1000; ++ } ++ } ++ ++ return utimes(path, &tv[0]); ++} ++ + char * + qemu_get_local_state_pathname(const char *relative_pathname) + { diff --git a/0008-Revert-linux-user-Use-safe_syscall-wrapper-for-fcntl.patch b/0008-Revert-linux-user-Use-safe_syscall-wrapper-for-fcntl.patch new file mode 100644 index 000000000000..a1defa6f5f02 --- /dev/null +++ b/0008-Revert-linux-user-Use-safe_syscall-wrapper-for-fcntl.patch @@ -0,0 +1,144 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 29 Jan 2020 12:42:08 +0000 +Subject: [PATCH] Revert "linux-user: Use safe_syscall wrapper for fcntl" + +This reverts commit 435da5e7092aa54e12044b9401b42c4a9333c74d. + +Conflicts: + linux-user/syscall.c + slirp +--- + linux-user/syscall.c | 40 ++++++++++++++-------------------------- + 1 file changed, 14 insertions(+), 26 deletions(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index 925c6111a59832300dd1fc93cef06e7bedce5c64..847fa04b71ac2a94343539adb97d77d2b2e38661 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -732,16 +732,6 @@ safe_syscall6(ssize_t, copy_file_range, int, infd, loff_t *, pinoff, + * the libc function. + */ + #define safe_ioctl(...) safe_syscall(__NR_ioctl, __VA_ARGS__) +-/* Similarly for fcntl. Note that callers must always: +- * pass the F_GETLK64 etc constants rather than the unsuffixed F_GETLK +- * use the flock64 struct rather than unsuffixed flock +- * This will then work and use a 64-bit offset for both 32-bit and 64-bit hosts. +- */ +-#ifdef __NR_fcntl64 +-#define safe_fcntl(...) safe_syscall(__NR_fcntl64, __VA_ARGS__) +-#else +-#define safe_fcntl(...) safe_syscall(__NR_fcntl, __VA_ARGS__) +-#endif + + static inline int host_to_target_sock_type(int host_type) + { +@@ -7018,7 +7008,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) + if (ret) { + return ret; + } +- ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); ++ ret = get_errno(fcntl(fd, host_cmd, &fl64)); + if (ret == 0) { + ret = copy_to_user_flock(arg, &fl64); + } +@@ -7030,7 +7020,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) + if (ret) { + return ret; + } +- ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); ++ ret = get_errno(fcntl(fd, host_cmd, &fl64)); + break; + + case TARGET_F_GETLK64: +@@ -7039,7 +7029,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) + if (ret) { + return ret; + } +- ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); ++ ret = get_errno(fcntl(fd, host_cmd, &fl64)); + if (ret == 0) { + ret = copy_to_user_flock64(arg, &fl64); + } +@@ -7052,25 +7042,23 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) + if (ret) { + return ret; + } +- ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); ++ ret = get_errno(fcntl(fd, host_cmd, &fl64)); + break; + + case TARGET_F_GETFL: +- ret = get_errno(safe_fcntl(fd, host_cmd, arg)); ++ ret = get_errno(fcntl(fd, host_cmd, arg)); + if (ret >= 0) { + ret = host_to_target_bitmask(ret, fcntl_flags_tbl); + } + break; + + case TARGET_F_SETFL: +- ret = get_errno(safe_fcntl(fd, host_cmd, +- target_to_host_bitmask(arg, +- fcntl_flags_tbl))); ++ ret = get_errno(fcntl(fd, host_cmd, target_to_host_bitmask(arg, fcntl_flags_tbl))); + break; + + #ifdef F_GETOWN_EX + case TARGET_F_GETOWN_EX: +- ret = get_errno(safe_fcntl(fd, host_cmd, &fox)); ++ ret = get_errno(fcntl(fd, host_cmd, &fox)); + if (ret >= 0) { + if (!lock_user_struct(VERIFY_WRITE, target_fox, arg, 0)) + return -TARGET_EFAULT; +@@ -7088,16 +7076,16 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) + fox.type = tswap32(target_fox->type); + fox.pid = tswap32(target_fox->pid); + unlock_user_struct(target_fox, arg, 0); +- ret = get_errno(safe_fcntl(fd, host_cmd, &fox)); ++ ret = get_errno(fcntl(fd, host_cmd, &fox)); + break; + #endif + + case TARGET_F_SETSIG: +- ret = get_errno(safe_fcntl(fd, host_cmd, target_to_host_signal(arg))); ++ ret = get_errno(fcntl(fd, host_cmd, target_to_host_signal(arg))); + break; + + case TARGET_F_GETSIG: +- ret = host_to_target_signal(get_errno(safe_fcntl(fd, host_cmd, arg))); ++ ret = host_to_target_signal(get_errno(fcntl(fd, host_cmd, arg))); + break; + + case TARGET_F_SETOWN: +@@ -7108,11 +7096,11 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) + case TARGET_F_GETPIPE_SZ: + case TARGET_F_ADD_SEALS: + case TARGET_F_GET_SEALS: +- ret = get_errno(safe_fcntl(fd, host_cmd, arg)); ++ ret = get_errno(fcntl(fd, host_cmd, arg)); + break; + + default: +- ret = get_errno(safe_fcntl(fd, cmd, arg)); ++ ret = get_errno(fcntl(fd, cmd, arg)); + break; + } + return ret; +@@ -11843,7 +11831,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, + if (ret) { + break; + } +- ret = get_errno(safe_fcntl(arg1, cmd, &fl)); ++ ret = get_errno(fcntl(arg1, cmd, &fl)); + if (ret == 0) { + ret = copyto(arg3, &fl); + } +@@ -11855,7 +11843,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, + if (ret) { + break; + } +- ret = get_errno(safe_fcntl(arg1, cmd, &fl)); ++ ret = get_errno(fcntl(arg1, cmd, &fl)); + break; + default: + ret = do_fcntl(arg1, arg2, arg3); diff --git a/0009-make-sure-mode-is-passed-to-openat-if-O_TMPFILE-is-s.patch b/0009-make-sure-mode-is-passed-to-openat-if-O_TMPFILE-is-s.patch new file mode 100644 index 000000000000..29c02894fbc0 --- /dev/null +++ b/0009-make-sure-mode-is-passed-to-openat-if-O_TMPFILE-is-s.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Wed, 29 Jan 2020 11:12:24 +0000 +Subject: [PATCH] make sure mode is passed to openat if O_TMPFILE is specified. + JB#45765 + +--- + linux-user/syscall.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index 847fa04b71ac2a94343539adb97d77d2b2e38661..ceef613e5664f6c4ab1831a727aa85cbd2f56eea 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -445,7 +445,7 @@ static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) + * open(2) has extra parameter 'mode' when called with + * flag O_CREAT. + */ +- if ((flags & O_CREAT) != 0) { ++ if ((flags & O_CREAT) != 0 || ((flags) & O_TMPFILE) == O_TMPFILE) { + return (openat(dirfd, pathname, flags, mode)); + } + return (openat(dirfd, pathname, flags)); diff --git a/0010-linux-user-disable-commpage.patch b/0010-linux-user-disable-commpage.patch new file mode 100644 index 000000000000..0a58a169d67e --- /dev/null +++ b/0010-linux-user-disable-commpage.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Frajo Haider <f_haider@gmx.at> +Date: Tue, 8 Dec 2020 00:19:06 +0200 +Subject: [PATCH] linux-user: disable commpage + +--- + linux-user/elfload.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index c45da4d63375978b9a4b37c39af3d7d3d008bc1e..be40c3078ef799bfb631f94a3eed04ac9da0c94d 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c +@@ -390,8 +390,10 @@ enum { + + /* The commpage only exists for 32 bit kernels */ + +-#define HI_COMMPAGE (intptr_t)0xffff0f00u ++#define HI_COMMPAGE 0 ++#define init_guest_commpage() true + ++#if 0 + static bool init_guest_commpage(void) + { + void *want = g2h_untagged(HI_COMMPAGE & -qemu_host_page_size); +@@ -415,6 +417,7 @@ static bool init_guest_commpage(void) + } + return true; + } ++#endif + + #define ELF_HWCAP get_elf_hwcap() + #define ELF_HWCAP2 get_elf_hwcap2() diff --git a/0011-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch b/0011-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch new file mode 100644 index 000000000000..9e235118d757 --- /dev/null +++ b/0011-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch @@ -0,0 +1,89 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Stefan Hajnoczi <stefanha@redhat.com> +Date: Wed, 27 Apr 2022 15:35:37 +0100 +Subject: [PATCH] virtio-scsi: don't waste CPU polling the event virtqueue + +The virtio-scsi event virtqueue is not emptied by its handler function. +This is typical for rx virtqueues where the device uses buffers when +some event occurs (e.g. a packet is received, an error condition +happens, etc). + +Polling non-empty virtqueues wastes CPU cycles. We are not waiting for +new buffers to become available, we are waiting for an event to occur, +so it's a misuse of CPU resources to poll for buffers. + +Introduce the new virtio_queue_aio_attach_host_notifier_no_poll() API, +which is identical to virtio_queue_aio_attach_host_notifier() except +that it does not poll the virtqueue. + +Before this patch the following command-line consumed 100% CPU in the +IOThread polling and calling virtio_scsi_handle_event(): + + $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \ + --object iothread,id=iothread0 \ + --device virtio-scsi-pci,iothread=iothread0 \ + --blockdev file,filename=test.img,aio=native,cache.direct=on,node-name=drive0 \ + --device scsi-hd,drive=drive0 + +After this patch CPU is no longer wasted. + +Reported-by: Nir Soffer <nsoffer@redhat.com> +Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> +Tested-by: Nir Soffer <nsoffer@redhat.com> +Message-id: 20220427143541.119567-3-stefanha@redhat.com +Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> +--- + hw/scsi/virtio-scsi-dataplane.c | 2 +- + hw/virtio/virtio.c | 13 +++++++++++++ + include/hw/virtio/virtio.h | 1 + + 3 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c +index 29575cbaf660c9aede738418030287eb58b4e2cd..8bb6e6acfce6d712f41a57ee815436e1dd5e6a1d 100644 +--- a/hw/scsi/virtio-scsi-dataplane.c ++++ b/hw/scsi/virtio-scsi-dataplane.c +@@ -138,7 +138,7 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) + + aio_context_acquire(s->ctx); + virtio_queue_aio_attach_host_notifier(vs->ctrl_vq, s->ctx); +- virtio_queue_aio_attach_host_notifier(vs->event_vq, s->ctx); ++ virtio_queue_aio_attach_host_notifier_no_poll(vs->event_vq, s->ctx); + + for (i = 0; i < vs->conf.num_queues; i++) { + virtio_queue_aio_attach_host_notifier(vs->cmd_vqs[i], s->ctx); +diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c +index 9d637e043e6b50025b61f612f63190449177f786..67a873f54a78aa00331615740e919f2d755a7d33 100644 +--- a/hw/virtio/virtio.c ++++ b/hw/virtio/virtio.c +@@ -3534,6 +3534,19 @@ void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx) + virtio_queue_host_notifier_aio_poll_end); + } + ++/* ++ * Same as virtio_queue_aio_attach_host_notifier() but without polling. Use ++ * this for rx virtqueues and similar cases where the virtqueue handler ++ * function does not pop all elements. When the virtqueue is left non-empty ++ * polling consumes CPU cycles and should not be used. ++ */ ++void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx) ++{ ++ aio_set_event_notifier(ctx, &vq->host_notifier, true, ++ virtio_queue_host_notifier_read, ++ NULL, NULL); ++} ++ + void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx) + { + aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL, NULL); +diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h +index b31c4507f5ddeb3ce96865138911bd7844836400..b62a35fdca00f9ac0a8e51a37d4a35b3144c82b6 100644 +--- a/include/hw/virtio/virtio.h ++++ b/include/hw/virtio/virtio.h +@@ -317,6 +317,7 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq); + void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled); + void virtio_queue_host_notifier_read(EventNotifier *n); + void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx); ++void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx); + void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx); + VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector); + VirtQueue *virtio_vector_next_queue(VirtQueue *vq); diff --git a/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch b/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch new file mode 100644 index 000000000000..d0aa69892b0e --- /dev/null +++ b/0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch @@ -0,0 +1,106 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Stefan Hajnoczi <stefanha@redhat.com> +Date: Wed, 27 Apr 2022 15:35:36 +0100 +Subject: [PATCH] virtio-scsi: fix ctrl and event handler functions in + dataplane mode + +Commit f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare +virtio_scsi_handle_cmd for dataplane") prepared the virtio-scsi cmd +virtqueue handler function to be used in both the dataplane and +non-datpalane code paths. + +It failed to convert the ctrl and event virtqueue handler functions, +which are not designed to be called from the dataplane code path but +will be since the ioeventfd is set up for those virtqueues when +dataplane starts. + +Convert the ctrl and event virtqueue handler functions now so they +operate correctly when called from the dataplane code path. Avoid code +duplication by extracting this code into a helper function. + +Fixes: f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane") +Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> +Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> +Message-id: 20220427143541.119567-2-stefanha@redhat.com +[Fixed s/by used/be used/ typo pointed out by Michael Tokarev +<mjt@tls.msk.ru>. +--Stefan] +Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> +--- + hw/scsi/virtio-scsi.c | 42 +++++++++++++++++++++++++++--------------- + 1 file changed, 27 insertions(+), 15 deletions(-) + +diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c +index 34a968ecfb5b45d5b2f09aef052197aceab4728e..417fbc71d66340c38f285d3d77912b675eb4947e 100644 +--- a/hw/scsi/virtio-scsi.c ++++ b/hw/scsi/virtio-scsi.c +@@ -472,16 +472,32 @@ bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq) + return progress; + } + ++/* ++ * If dataplane is configured but not yet started, do so now and return true on ++ * success. ++ * ++ * Dataplane is started by the core virtio code but virtqueue handler functions ++ * can also be invoked when a guest kicks before DRIVER_OK, so this helper ++ * function helps us deal with manually starting ioeventfd in that case. ++ */ ++static bool virtio_scsi_defer_to_dataplane(VirtIOSCSI *s) ++{ ++ if (!s->ctx || s->dataplane_started) { ++ return false; ++ } ++ ++ virtio_device_start_ioeventfd(&s->parent_obj.parent_obj); ++ return !s->dataplane_fenced; ++} ++ + static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) + { + VirtIOSCSI *s = (VirtIOSCSI *)vdev; + +- if (s->ctx) { +- virtio_device_start_ioeventfd(vdev); +- if (!s->dataplane_fenced) { +- return; +- } ++ if (virtio_scsi_defer_to_dataplane(s)) { ++ return; + } ++ + virtio_scsi_acquire(s); + virtio_scsi_handle_ctrl_vq(s, vq); + virtio_scsi_release(s); +@@ -720,12 +736,10 @@ static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq) + /* use non-QOM casts in the data path */ + VirtIOSCSI *s = (VirtIOSCSI *)vdev; + +- if (s->ctx && !s->dataplane_started) { +- virtio_device_start_ioeventfd(vdev); +- if (!s->dataplane_fenced) { +- return; +- } ++ if (virtio_scsi_defer_to_dataplane(s)) { ++ return; + } ++ + virtio_scsi_acquire(s); + virtio_scsi_handle_cmd_vq(s, vq); + virtio_scsi_release(s); +@@ -855,12 +869,10 @@ static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq) + { + VirtIOSCSI *s = VIRTIO_SCSI(vdev); + +- if (s->ctx) { +- virtio_device_start_ioeventfd(vdev); +- if (!s->dataplane_fenced) { +- return; +- } ++ if (virtio_scsi_defer_to_dataplane(s)) { ++ return; + } ++ + virtio_scsi_acquire(s); + virtio_scsi_handle_event_vq(s, vq); + virtio_scsi_release(s); diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..d70472dae506 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,272 @@ +# Maintainer: Björn Bidar <AUR+me@thaodan.de> +# Vanilla package Maintainer: David Runge <dvzrv@archlinux.org> +# Contributor: Tobias Powalowski <tpowa@archlinux.org> +# Contributor: Sébastien "Seblu" Luttringer <seblu@seblu.net> + +_pkgbase=qemu +pkgbase=$_pkgbase-scratchbox2 +pkgname=( + $pkgbase-tests + $pkgbase-user +) +pkgver=7.0.0 +pkgrel=10 +_pkgdesc_suffix="patched for use with scratchbox2" +pkgdesc="A generic and open source machine emulator and virtualizer $_pkgdesc_suffix" +arch=(x86_64) +url="https://www.qemu.org/" +license=(GPL2 LGPL2.1) +# TODO: consider providing rdma-core +# TODO: consider providing lzfse +# TODO: package systemtap +# TODO: package openbios for qemu-system-{ppc,sparc} +# TODO: package /usr/share/qemu/{efi,pxe}-* for qemu (ipxe) +# TODO: package /usr/share/qemu/slof.bin for qemu-system-ppc (slof) +# TODO: package /usr/share/qemu/sgabios.bin for qemu-system-x86 (sgabios) +# TODO: package static libs of glib2 and pcre for qemu-user-static +makedepends=( + alsa-lib + brltty + bzip2 + cairo + ceph + curl + dtc + fuse3 + gcc-libs + gdk-pixbuf2 + glib2 + glusterfs + gnutls + gtk3 + jack + libaio + libbpf + libcacard + libcap-ng + libepoxy + libiscsi + libnfs + libpng + libpulse + libsasl + libseccomp + libslirp + libssh + liburing + libusb + libx11 + libxml2 + libxkbcommon + lzo + mesa + meson + multipath-tools + ncurses + ndctl + numactl + pam + python + python-sphinx + python-sphinx_rtd_theme + sdl2 + sdl2_image + snappy + spice-protocol + spice + systemd + usbredir + vde2 + virglrenderer + vte3 + zlib + zstd +) +# NOTE: currently the debug package for qemu >= 7.0.0 contains an invalid /build dir +options=(debug) +source=( + https://download.qemu.org/qemu-$pkgver.tar.xz{,.sig} + 0001-Revert-linux-user-Use-safe_syscall-for-open-and-open.patch + 0002-Revert-linux-user-Use-safe_syscall-for-execve-syscal.patch + 0003-Revert-linux-user-Use-safe_syscall-wrapper-for-send-.patch + 0004-Revert-linux-user-Use-safe_syscall-wrapper-for-accep.patch + 0005-Revert-linux-user-Use-safe_syscall-wrapper-for-conne.patch + 0006-Revert-linux-user-Use-direct-syscall-for-utimensat.patch + 0007-Revert-util-drop-old-utimensat-compat-code.patch + 0008-Revert-linux-user-Use-safe_syscall-wrapper-for-fcntl.patch + 0009-make-sure-mode-is-passed-to-openat-if-O_TMPFILE-is-s.patch + 0010-linux-user-disable-commpage.patch + 0011-virtio-scsi-don-t-waste-CPU-polling-the-event-virtqu.patch + 0012-virtio-scsi-fix-ctrl-and-event-handler-functions-in-.patch +) +sha512sums=('44ecd10c018a3763e1bc87d1d35b98890d0d5636acd69fe9b5cadf5024d5af6a31684d60cbe1c3370e02986434c1fb0ad99224e0e6f6fe7eda169992508157b1' + 'SKIP' + 'b8f16f8e73a05aba0caab7844700ee57dcd9aba337a58a5a6b862ac4642919378ca9532972b760b42a65f48730ab96a4c5e4bd68af7f42b0e18a5e050a68539d' + '124b4be68e3949293c0c90cee8c6da719c871426e83fbc9e52597d02dfaf79ce95ed12373e3d0bafbd83f019fd6e254ec91651dab17a868c06b7eaa8abc1e19a' + '37626ac06af37a324f4912dff689b52a9b3da27e08a0029ad2dd0855137fae8b3aacb873456897298f9a4fb28e4f04929477ab433ede0e6e9cb3534657114233' + 'b173e735ce7f81c4ad986d8b6d774663957e59ee025cd153f6b016c5687a7d62a82b031e5956dd7b8ecf086addc38b1a509d7c3180988bdd7333847557781c9f' + '520697682261e89017b091f3ce16a1bab8be18d2291a9febf9eb7ed8e1a54422eb3a26e96f16d8994d50ca73f6e08f3df7dc5130fadffe5cf9c52c779d501c51' + 'c0c74faab1685107b0e83e76e5a592966d3e3497191cf32b3d84fff70feac1ebdbcf3d8a481fdddfd04d79883e3155db9564c9a51b279a83cf650b248d76b033' + '6fb03b29ea9a3c2ab13da01d97c735b2b28dbe262cd18f068f21ce5b808cab0042c2f22b5066da744255ac380104b8740d02754fe11c3e4f0e864bbf6e46336a' + '9db86e41e7725fd670625b78341a4b5c20e8271b4ab2673cda153696cb57f662bd5383f96c887a41a629cf8c35ed36f6a20f8b8bec23ab7cbf3621695ff7d697' + 'ef057bf82dd81bbf4fd1270876698efc69e5f9c4f34c4b424e6562eeed64a8fa70126b192c041d342e7b44369223d79b587198a2a07d0cef16c03305a75d7b00' + '57f4b72df80333e457bbc6a9afa47af40dcd59a32d55a7babda5b5378f9485282823c50e2baca54230fc77056303e809b2108b9ffb73d64eab7eedbf67303ab5' + '4c66df5ffbae302bf0a2f5f6aab1536ac00b5e57eab94e69f7fbd79f54fefa47c46ca20c3b039fd7e51ee72bc74142ab7a94ec2e64f653682992a7df30867d9b' + '155b3de89a18fa8cb234ce71767dbf59ab4e0ed2c6375279413fa2c11c128d46bdc2c28467fdbe226e2188755cecae2e33c964f7a35806882a173551d9765684') +b2sums=('ceda6d9f1a585298bd49fed61e8bb35f0064ad8388a9f979c8bd68a38bfe1a47c5bb055e5f74f970c2c440957042b9de4a861524120040c56e4cd8b56c5cfb68' + 'SKIP' + '0f591ed6d4d1356d75039429da7711f03bbafff8014ef47ab3b7683111d30c4a535ab79c5701984b3a04af74cd6b2d395fe1da942eb4da43cf08f16753b6024e' + 'b0d553e58da26f33003ab95b3910b98e0a14ef0719facef01c8cf22facec20fd29a1f5bae6f7301c53bd23e02abfd7cedfbfb263a558f4c4eea808a157b2c6b4' + 'e70c3ea01afd75c2489d106a2464f4bd8d9b373a8a3147d0a5fb77ebc5587b66c2924bd11a2c2a61359f080e20071810faed299f9bab3816ac2142360a54deb3' + 'c113c1297de8222d413c8715de2e35fc7166ea3064e04de4242e59eb1f283c38589ccc26c21e1937eb1f0d935dc3aba55ab5b549efb02a27ca3ae880c10f1b47' + '2e5d5aa1c98142c55f94104d40116ff8baf8a1a995704ec86d164455d840fcf210e68093790e6968c357dafce0cf8ab600d53fd692887563186a571e2d3f3b93' + '0aae840a656c05c10c9d10d1894869e472e3415af3895d35bdd86fdb77c597c157ee867a77a202ef2e81d6a89eeb086a1b86ff396276fc31f61d5a1566c1af15' + '9d067a955d1ecaf838fa24161af32d4402308af1c24364a13357ffc39abd4ce346b27af40642e5236aec8af85748329c2f736ee386f2e2f802fa335d56a1b8d5' + '975d48c77fb62876e19f2548572c46b19d34e3836c42f482b35759dd3405c9601d6030009a56336a55e1d0baf049632de77ad8928660ccbc6fb42bff27d5d720' + '5972d7524bd3d1b3c37f68c4d23358eac4bf68762a857362caff5ebe90480b6ff8d18f8a667d3b88b908cad75de6a5140a23471deea75394afc99904d550fd90' + '28654ef9a6cab7a9e2408c44de9769fb5772141eb8253058f147b807cf46ed25b72dc404addb09cc9495f9f872b0af8859f7d75d597ad3c1b33f05c17e3e00d3' + 'd7c3b91fa4ed217d9df1d2cb0fbf696ed81fcbcb15f15fc631a75aef4e45dc51ef58d6f9db40eea274c8b745d76a4c6fbad4357a85bdbba12c6b342cd7020576' + 'd02aaaa9763740c6e46fa66d1247e441c396ebc9d0351c86c913629d47f4e64fea23ee7b4376234f8d33bd5a67f109e2d7e485bb078327ec9b3e5271982d07cc') +validpgpkeys=('CEACC9E15534EBABB82D3FA03353C9CEF108B584') # Michael Roth <flukshun@gmail.com> + +_qemu_system_deps=( + dtc + fuse3 + gcc-libs + glib2 libgio-2.0.so libglib-2.0.so libgmodule-2.0.so + gnutls + libaio + libbpf libbpf.so + libjpeg-turbo libjpeg.so + libpng + libsasl + libseccomp libseccomp.so + libslirp libslirp.so + liburing liburing.so + lzo + ndctl + numactl libnuma.so + pam libpam.so + pixman libpixman-1.so + qemu-common + snappy + vde2 + zlib + zstd libzstd.so +) + +_pick() { + local p="$1" f d; shift + for f; do + d="$srcdir/$p/${f#$pkgdir/}" + mkdir -p "$(dirname "$d")" + mv "$f" "$d" + rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")" + done +} + +prepare() { + # extract licenses for TCG + sed -n '1,23p' $_pkgbase-$pkgver/tcg/tcg-internal.h > tcg.LICENSE.MIT + sed -n '1,23p' $_pkgbase-$pkgver/tcg/arm/tcg-target.c.inc > tcg-arm.LICENSE.MIT + sed -n '1,23p' $_pkgbase-$pkgver/tcg/tci/tcg-target.h > tci.LICENSE.MIT + + # install qemu-pr-helper.socket to sockets.target + sed -e 's/multi-user.target/sockets.target/g' -i $_pkgbase-$pkgver/contrib/systemd/qemu-pr-helper.socket + + # create build dir + mkdir -vp build + mkdir -vp build-static + + # fix issues with virtio-scsi https://lists.gnu.org/archive/html/qemu-devel/2022-04/msg04724.html + cd $_pkgbase-$pkgver + for patch in ${srcdir}/*.patch ; do + patch -p1 -i "$patch" + done +} + +build() { + # Build only minimal debug info to reduce size + CFLAGS+=' -g1' + CXXFLAGS+=' -g1' + + + ( + cd build + + # LTO needs more open files + ulimit -n 50000 + + ../$_pkgbase-$pkgver/configure \ + --prefix=/usr \ + --sysconfdir=/etc \ + --libexecdir=/usr/lib/qemu \ + --localstatedir=/var \ + --docdir=/usr/share/doc/qemu \ + --enable-modules \ + --enable-sdl \ + --enable-slirp=system \ + --enable-tpm \ + --smbd=/usr/bin/smbd \ + --tls-priority=@QEMU,SYSTEM \ + --with-coroutine=ucontext + ninja -j $(($(nproc)/4)) + ) + + # TODO: qemu-user-static + # ( + # cd build-static + # ../$_pkgbase-$pkgver/configure \ + # --enable-attr \ + # --enable-linux-user \ + # --enable-tcg \ + # --disable-install-blobs \ + # --static + # ninja + # ) + + meson install -C build --destdir "$srcdir"/_pkgdir + install -vdm 755 "$srcdir"/_pkgdir/usr/lib/binfmt.d/ + $_pkgbase-$pkgver/scripts/qemu-binfmt-conf.sh --systemd ALL \ + --exportdir \ + "$srcdir"/_pkgdir/usr/lib/binfmt.d/ --qemu-path "/usr/bin" + ( + # pick files for all split packages + cd "$srcdir/_pkgdir" + + _pick qemu-scratchbox2-user usr/bin/qemu-{aarch64{,_be},alpha,arm{,eb},cris,hexagon,hppa,i386,m68k,microblaze{,el},mips{,64,64el,el,n32,n32el},nios2,or1k,ppc{,64,64le},riscv{32,64},s390x,sh4{,eb},sparc{,32plus,64},x86_64,xtensa{,eb}} + _pick qemu-scratchbox2-user usr/lib/binfmt.d/*.conf + _pick qemu-scratchbox2-tests usr/lib/qemu/accel-qtest-*.so + ) +} + + +package_qemu-scratchbox2-tests() { + pkgdesc="QEMU tests $_pkgdesc_suffix" + depends=(qemu-common) + provides=($_pkgbase-tests) + conflicts=($_pkgbase-tests) + mv -v $pkgname/* "$pkgdir" +} + +package_qemu-scratchbox2-user() { + pkgdesc="QEMU user mode emulation $_pkgdesc_suffix" + depends=(gcc-libs glib2 libglib-2.0.so libgmodule-2.0.so glibc gnutls + liburing liburing.so qemu-common zlib) + provides=($_pkgbase-user) + conflicts=($_pkgbase-user) + mv -v $pkgname/* "$pkgdir" + install -vdm 755 "$pkgdir/usr/lib/binfmt.d/" +} + +# package_qemu-user-static() { +# pkgdesc="QEMU static user mode emulation $_pkgdesc_suffix" +# depends=(glibc) +# mv -v $pkgname/* "$pkgdir" +# } + + + + + +# vim:set ts=2 sw=2 et: |