+Discussion:
https://resin.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub/
+
https://github.com/resin-io/qemu/commit/782e5bb77014ff136f7bb6133a911e5f53e914a7
https://github.com/resin-io/qemu/commit/782e5bb77014ff136f7bb6133a911e5f53e914a7#commitcomment-17193923
v3 changes:
- rebase the patchset against current code
---- qemu-2.7.0/linux-user/main.c~ 2016-09-26 12:07:20.000000000 +0300
-+++ qemu-2.7.0/linux-user/main.c 2016-09-26 12:09:24.258470304 +0300
-@@ -18,6 +18,7 @@
- */
- #include "qemu/osdep.h"
- #include "qemu-version.h"
-+#include <sys/auxv.h>
- #include <sys/syscall.h>
- #include <sys/resource.h>
-
-@@ -75,6 +76,7 @@ static void usage(int exitcode);
+diff --git a/linux-user/main.c b/linux-user/main.c
+index ee12035..5951279 100644
+--- a/linux-user/main.c
++++ b/linux-user/main.c
+@@ -79,6 +79,7 @@ static void usage(int exitcode);
static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
const char *qemu_uname_release;
/* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
we allocate a bigger stack. Need a better solution, for example
-@@ -3824,6 +3826,38 @@ static void handle_arg_guest_base(const char *arg)
+@@ -3828,6 +3829,11 @@ static void handle_arg_guest_base(const char *arg)
have_guest_base = 1;
}
+static void handle_arg_execve(const char *arg)
+{
-+ const char *execfn;
-+ char buf[PATH_MAX];
-+ char *ret;
-+ int len;
-+
-+ /* try getauxval() */
-+ execfn = (const char *) getauxval(AT_EXECFN);
-+
-+ if (execfn != 0) {
-+ ret = realpath(execfn, buf);
-+
-+ if (ret != NULL) {
-+ qemu_execve_path = strdup(buf);
-+ return;
-+ }
-+ }
-+
-+ /* try /proc/self/exe */
-+ len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
-+
-+ if (len != -1) {
-+ buf[len] = '\0';
-+ qemu_execve_path = strdup(buf);
-+ return;
-+ }
-+
-+ fprintf(stderr, "qemu_execve: unable to determine intepreter's path\n");
-+ exit(EXIT_FAILURE);
++ qemu_execve_path = strdup(arg);
+}
+
static void handle_arg_reserved_va(const char *arg)
{
char *p;
-@@ -3909,6 +3943,8 @@ static const struct qemu_argument arg_table[] = {
+@@ -3913,6 +3919,8 @@ static const struct qemu_argument arg_table[] = {
"uname", "set qemu uname release string to 'uname'"},
{"B", "QEMU_GUEST_BASE", true, handle_arg_guest_base,
"address", "set guest_base address to 'address'"},
-+ {"execve", "QEMU_EXECVE", false, handle_arg_execve,
-+ "", "use this interpreter when a process calls execve()"},
++ {"execve", "QEMU_EXECVE", true, handle_arg_execve,
++ "path", "use interpreter at 'path' when a process calls execve()"},
{"R", "QEMU_RESERVED_VA", true, handle_arg_reserved_va,
"size", "reserve 'size' bytes for guest virtual address space"},
{"d", "QEMU_LOG", true, handle_arg_log,
extern unsigned long mmap_min_addr;
/* ??? See if we can avoid exposing so much of the loader internals. */
---- qemu-2.7.0/linux-user/syscall.c~ 2016-09-26 12:10:36.000000000 +0300
-+++ qemu-2.7.0/linux-user/syscall.c 2016-09-26 12:13:54.312490312 +0300
-@@ -99,6 +99,7 @@
- #include <linux/reboot.h>
- #include <linux/route.h>
- #include <linux/filter.h>
-+#include <linux/binfmts.h>
- #include <linux/blkpg.h>
- #include <netpacket/packet.h>
- #include <linux/netlink.h>
-@@ -5842,6 +5843,118 @@ static target_timer_t get_timer_id(abi_long arg)
+--- qemu-2.12.0/linux-user/syscall.c~ 2018-04-30 21:43:39.000000000 +0300
++++ qemu-2.12.0/linux-user/syscall.c 2018-04-30 21:46:36.362935706 +0300
+@@ -5854,6 +5854,109 @@ static target_timer_t get_timer_id(abi_long arg)
return timerid;
}
++#define BINPRM_BUF_SIZE 128
++
+/* qemu_execve() Must return target values and target errnos. */
+static abi_long qemu_execve(char *filename, char *argv[],
+ char *envp[])
+ char *cp;
+ char buf[BINPRM_BUF_SIZE];
+
-+ /* normal execve case */
-+ if (qemu_execve_path == NULL || *qemu_execve_path == 0) {
-+ return get_errno(execve(filename, argv, envp));
-+ }
-+
+ for (argc = 0; argv[argc] != NULL; argc++) {
+ /* nothing */ ;
+ }
+
+ fd = open(filename, O_RDONLY);
+ if (fd == -1) {
-+ return get_errno(fd);
++ return -ENOENT;
+ }
+
+ ret = read(fd, buf, BINPRM_BUF_SIZE);
+ if (ret == -1) {
+ close(fd);
-+ return get_errno(ret);
-+ }
-+
-+ /* if we have less than 2 bytes, we can guess it is not executable */
-+ if (ret < 2) {
-+ close(fd);
-+ return -host_to_target_errno(ENOEXEC);
++ return -ENOENT;
+ }
+
+ close(fd);
+ buf[BINPRM_BUF_SIZE - 1] = '\0';
+ cp = strchr(buf, '\n');
+ if (cp == NULL) {
-+ cp = buf + BINPRM_BUF_SIZE - 1;
++ cp = buf+BINPRM_BUF_SIZE-1;
+ }
+ *cp = '\0';
+ while (cp > buf) {
+ break;
+ }
+ }
-+ for (cp = buf + 2; (*cp == ' ') || (*cp == '\t'); cp++) {
++ for (cp = buf+2; (*cp == ' ') || (*cp == '\t'); cp++) {
+ /* nothing */ ;
+ }
+ if (*cp == '\0') {
/* do_syscall() should always have a single exit point at the end so
that actions, such as logging of syscall results, can be performed.
All errnos that do_syscall() returns must be -TARGET_<errcode>. */
-@@ -7703,7 +7703,7 @@
+@@ -8257,7 +8257,12 @@
* before the execve completes and makes it the other
* program's problem.
*/
- ret = get_errno(safe_execve(p, argp, envp));
-+ ret = qemu_execve(p, argp, envp);
++ if (qemu_execve_path && *qemu_execve_path) {
++ ret = get_errno(qemu_execve(p, argp, envp));
++ } else {
++ ret = get_errno(safe_execve(p, argp, envp));
++ }
++
unlock_user(p, arg1, 0);
goto execve_end;
Summary: QEMU CPU Emulator
Summary(pl.UTF-8): QEMU - emulator procesora
Name: qemu
-Version: 2.11.1
+Version: 2.12.0
Release: 1
License: GPL v2
Group: Applications/Emulators
Source0: http://wiki.qemu-project.org/download/%{name}-%{version}.tar.xz
-# Source0-md5: 0ee48c0f0cae47cc5d05408e03cd199e
+# Source0-md5: ca553eb04c933f58111c304452fc4cc5
+Source2: %{name}.binfmt
# Loads kvm kernel modules at boot
Source3: kvm-modules-load.conf
# Creates /dev/kvm
Patch4: %{name}-xattr.patch
Patch5: libjpeg-boolean.patch
Patch6: x32.patch
-Patch7: %{name}-glibc2_27.patch
URL: http://www.qemu-project.org/
%{?with_gl:BuildRequires: OpenGL-GLX-devel}
%{?with_gl:BuildRequires: OpenGL-devel}
BuildRequires: libfdt-devel >= 1.4.2
%{?with_rdma:BuildRequires: libibverbs-devel}
%{?with_iscsi:BuildRequires: libiscsi-devel >= 1.9.0}
+%{?with_rdma:BuildRequires: libibumad-devel}
BuildRequires: libjpeg-devel
%{?with_libnfs:BuildRequires: libnfs-devel >= 1.9.3}
BuildRequires: libpng-devel
BuildRequires: glib2-static
BuildRequires: glibc-static
BuildRequires: pcre-static
-BuildRequires: xen-static
BuildRequires: zlib-static
%endif
Requires: %{name}-img = %{version}-%{release}
Requires: %{name}-system-alpha = %{version}-%{release}
Requires: %{name}-system-arm = %{version}-%{release}
Requires: %{name}-system-cris = %{version}-%{release}
+Requires: %{name}-system-hppa = %{version}-%{release}
Requires: %{name}-system-lm32 = %{version}-%{release}
Requires: %{name}-system-m68k = %{version}-%{release}
Requires: %{name}-system-microblaze = %{version}-%{release}
Requires: %{name}-system-nios2 = %{version}-%{release}
Requires: %{name}-system-or1k = %{version}-%{release}
Requires: %{name}-system-ppc = %{version}-%{release}
+Requires: %{name}-system-riscv32 = %{version}-%{release}
+Requires: %{name}-system-riscv64 = %{version}-%{release}
Requires: %{name}-system-s390x = %{version}-%{release}
Requires: %{name}-system-sh4 = %{version}-%{release}
Requires: %{name}-system-sparc = %{version}-%{release}
Ten pakiet zawiera emulator systemu z procesorem CRIS.
+%package system-hppa
+Summary: QEMU system emulator for HP/PA
+Summary(pl.UTF-8): QEMU - emulator systemu z procesorem HP/PA
+Group: Development/Tools
+Requires: %{name}-common = %{version}-%{release}
+%systempkg_req
+
+%description system-hppa
+QEMU is a generic and open source processor emulator which achieves a
+good emulation speed by using dynamic translation.
+
+This package provides the system emulator with HP/PA CPU.
+
+%description system-hppa -l pl.UTF-8
+QEMU to ogólny, mający otwarte źródła emulator procesora, osiągający
+dobrą szybkość emulacji dzięki użyciu translacji dynamicznej.
+
+Ten pakiet zawiera emulator systemu z procesorem HP/PA.
+
%package system-lm32
Summary: QEMU system emulator for LM32
Summary(pl.UTF-8): QEMU - emulator systemu z procesorem LM32
Ten pakiet zawiera emulator systemu z procesorem PowerPC.
+%package system-riscv32
+Summary: QEMU system emulator for RISC-V (32 bit)
+Summary(pl.UTF-8): QEMU - emulator systemu z procesorem RISC-V (32 bit)
+Group: Development/Tools
+Requires: %{name}-common = %{version}-%{release}
+%systempkg_req
+
+%description system-riscv32
+QEMU is a generic and open source processor emulator which achieves a
+good emulation speed by using dynamic translation.
+
+This package provides the system emulator with RISC-V (32 bit) CPU.
+
+%description system-riscv32 -l pl.UTF-8
+QEMU to ogólny, mający otwarte źródła emulator procesora, osiągający
+dobrą szybkość emulacji dzięki użyciu translacji dynamicznej.
+
+Ten pakiet zawiera emulator systemu z procesorem RISC-V (32 bit).
+
+%package system-riscv64
+Summary: QEMU system emulator for RISC-V (64 bit)
+Summary(pl.UTF-8): QEMU - emulator systemu z procesorem RISC-V (64 bit)
+Group: Development/Tools
+Requires: %{name}-common = %{version}-%{release}
+%systempkg_req
+
+%description system-riscv64
+QEMU is a generic and open source processor emulator which achieves a
+good emulation speed by using dynamic translation.
+
+This package provides the system emulator with RISC-V (64 bit) CPU.
+
+%description system-riscv64 -l pl.UTF-8
+QEMU to ogólny, mający otwarte źródła emulator procesora, osiągający
+dobrą szybkość emulacji dzięki użyciu translacji dynamicznej.
+
+Ten pakiet zawiera emulator systemu z procesorem RISC-V (64 bit).
+
%package system-s390x
Summary: QEMU system emulator for S390
Summary(pl.UTF-8): QEMU - emulator systemu z procesorem S390
%description module-block-curl -l pl.UTF-8
Moduł QEMU dla urządeń blokowych typu 'curl'.
-%package module-block-dmg
-Summary: QEMU module for 'dmg' block devices
-Summary(pl.UTF-8): Moduł QEMU dla urządeń blokowych typu 'dmg'
-Group: Development/Tools
-Requires: %{name}-common = %{version}-%{release}
-Requires: bzip2-libs
-
-%description module-block-dmg
-'dmg' block device support for QEMU.
-
-%description module-block-dmg -l pl.UTF-8
-Moduł QEMU dla urządeń blokowych typu 'dmg'.
-
%package module-block-gluster
Summary: QEMU module for 'gluster' block devices
Summary(pl.UTF-8): Moduł QEMU dla urządeń blokowych typu 'gluster'
%description module-block-iscsi -l pl.UTF-8
Moduł QEMU dla urządeń blokowych typu 'iscsi'.
-%package module-block-nfs
-Summary: QEMU module for 'nfs' block devices
-Summary(pl.UTF-8): Moduł QEMU dla urządeń blokowych typu 'nfs'
-Group: Development/Tools
-Requires: %{name}-common = %{version}-%{release}
-Requires: libnfs >= 1.9.3
-
-%description module-block-nfs
-'nfs' block device support for QEMU.
-
-%description module-block-nfs -l pl.UTF-8
-Moduł QEMU dla urządeń blokowych typu 'nfs'.
-
%package module-block-rbd
Summary: QEMU module for 'rbd' block devices
Summary(pl.UTF-8): Moduł QEMU dla urządeń blokowych typu 'rbd'
%patch4 -p1
%patch5 -p1
%patch6 -p1
-%patch7 -p1
# workaround for conflict with alsa/error.h
ln -s ../error.h qapi/error.h
--enable-vnc-jpeg \
--enable-vnc-png \
--enable-vnc-sasl \
- %{__enable_disable vte} \
+ %{!?with_vte:--disable-vte} \
%{__enable_disable xen} \
--enable-modules \
--disable-netmap \
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT/etc/{qemu,sysconfig,udev/rules.d,modules-load.d} \
+install -d $RPM_BUILD_ROOT/usr/lib/binfmt.d \
+ $RPM_BUILD_ROOT/etc/{qemu,sysconfig,udev/rules.d,modules-load.d} \
$RPM_BUILD_ROOT{%{_sysconfdir}/sasl,%{_sbindir}}
%if %{with user_static}
install -p %{SOURCE9} $RPM_BUILD_ROOT%{_sbindir}/ksmtuned
install -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/ksmtuned.conf
+# For the qemu-guest-agent subpackage install the udev rules.
install -p %{SOURCE12} $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d
+# Install binfmt
+for i in dummy \
+%ifnarch %{ix86} %{x8664} x32
+ qemu-i386 \
+%endif
+%ifnarch alpha
+ qemu-alpha \
+%endif
+%ifnarch %{arm}
+ qemu-arm \
+%endif
+ qemu-armeb \
+ qemu-cris \
+ qemu-microblaze qemu-microblazeel \
+%ifnarch mips64
+ qemu-mips64 \
+%ifnarch mips
+ qemu-mips \
+%endif
+%endif
+%ifnarch mips64el
+ qemu-mips64el \
+%ifnarch mipsel
+ qemu-mipsel \
+%endif
+%endif
+%ifnarch m68k
+ qemu-m68k \
+%endif
+%ifnarch ppc ppc64 ppc64le
+ qemu-ppc qemu-ppc64abi32 qemu-ppc64 \
+%endif
+%ifnarch sparc sparc64
+ qemu-sparc qemu-sparc32plus qemu-sparc64 \
+%endif
+%ifnarch s390 s390x
+ qemu-s390x \
+%endif
+%ifnarch sh4
+ qemu-sh4 \
+%endif
+ qemu-sh4eb \
+; do
+ test $i = dummy && continue
+ grep /$i:\$ %{SOURCE2} > $RPM_BUILD_ROOT/usr/lib/binfmt.d/$i-dynamic.conf
+
+ %if %{with user_static}
+ grep /$i:\$ %{SOURCE2} > $RPM_BUILD_ROOT/usr/lib/binfmt.d/$i-static.conf
+ %{__sed} -i -e "s/$i/$i-static/" $RPM_BUILD_ROOT/usr/lib/binfmt.d/$i-static.conf
+ %endif
+done < %{SOURCE2}
+
# packaged as %doc
%{__rm} $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-doc.html
%dir %{_libdir}/%{name}
+# modules without too many external dependencies
+%attr(755,root,root) %{_libdir}/%{name}/block-dmg-bz2.so
+%attr(755,root,root) %{_libdir}/%{name}/block-nfs.so
+
+%attr(755,root,root) %{_libdir}/%{name}/audio-alsa.so
+%attr(755,root,root) %{_libdir}/%{name}/audio-pa.so
+%attr(755,root,root) %{_libdir}/%{name}/audio-sdl.so
+%attr(755,root,root) %{_libdir}/%{name}/ui-curses.so
+%attr(755,root,root) %{_libdir}/%{name}/ui-gtk.so
+%attr(755,root,root) %{_libdir}/%{name}/ui-sdl.so
+
%files img
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/qemu-img
%files user
%defattr(644,root,root,755)
+/usr/lib/binfmt.d/qemu-*-dynamic.conf
%attr(755,root,root) %{_bindir}/qemu-aarch64
+%attr(755,root,root) %{_bindir}/qemu-aarch64_be
%attr(755,root,root) %{_bindir}/qemu-alpha
%attr(755,root,root) %{_bindir}/qemu-arm
%attr(755,root,root) %{_bindir}/qemu-armeb
%attr(755,root,root) %{_bindir}/qemu-ppc64
%attr(755,root,root) %{_bindir}/qemu-ppc64abi32
%attr(755,root,root) %{_bindir}/qemu-ppc64le
+%attr(755,root,root) %{_bindir}/qemu-riscv32
+%attr(755,root,root) %{_bindir}/qemu-riscv64
%attr(755,root,root) %{_bindir}/qemu-s390x
%attr(755,root,root) %{_bindir}/qemu-sh4
%attr(755,root,root) %{_bindir}/qemu-sh4eb
%attr(755,root,root) %{_bindir}/qemu-sparc32plus
%attr(755,root,root) %{_bindir}/qemu-sparc64
%attr(755,root,root) %{_bindir}/qemu-x86_64
+%attr(755,root,root) %{_bindir}/qemu-xtensa
+%attr(755,root,root) %{_bindir}/qemu-xtensaeb
%if %{with user_static}
%files user-static
%defattr(644,root,root,755)
+/usr/lib/binfmt.d/qemu-*-static.conf
%attr(755,root,root) %{_bindir}/qemu-aarch64-static
+%attr(755,root,root) %{_bindir}/qemu-aarch64_be-static
%attr(755,root,root) %{_bindir}/qemu-alpha-static
%attr(755,root,root) %{_bindir}/qemu-arm-static
%attr(755,root,root) %{_bindir}/qemu-armeb-static
%attr(755,root,root) %{_bindir}/qemu-ppc64-static
%attr(755,root,root) %{_bindir}/qemu-ppc64abi32-static
%attr(755,root,root) %{_bindir}/qemu-ppc64le-static
+%attr(755,root,root) %{_bindir}/qemu-riscv32-static
+%attr(755,root,root) %{_bindir}/qemu-riscv64-static
%attr(755,root,root) %{_bindir}/qemu-s390x-static
%attr(755,root,root) %{_bindir}/qemu-sh4-static
%attr(755,root,root) %{_bindir}/qemu-sh4eb-static
%attr(755,root,root) %{_bindir}/qemu-sparc64-static
%attr(755,root,root) %{_bindir}/qemu-tilegx-static
%attr(755,root,root) %{_bindir}/qemu-x86_64-static
+%attr(755,root,root) %{_bindir}/qemu-xtensa-static
+%attr(755,root,root) %{_bindir}/qemu-xtensaeb-static
%endif
%files system-aarch64
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/qemu-system-cris
+%files system-hppa
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/qemu-system-hppa
+%{_datadir}/%{name}/hppa-firmware.img
+
%files system-lm32
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/qemu-system-lm32
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/qemu-system-ppc
%attr(755,root,root) %{_bindir}/qemu-system-ppc64
-#%attr(755,root,root) %{_bindir}/qemu-system-ppc64le
%attr(755,root,root) %{_bindir}/qemu-system-ppcemb
+%{_datadir}/%{name}/canyonlands.dtb
%{_datadir}/%{name}/qemu_vga.ndrv
%{_datadir}/%{name}/u-boot.e500
+%{_datadir}/%{name}/u-boot-sam460-20100605.bin
+
+%files system-riscv32
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/qemu-system-riscv32
+
+%files system-riscv64
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/qemu-system-riscv64
%files system-s390x
%defattr(644,root,root,755)
%endif
%{_datadir}/%{name}/bios.bin
%{_datadir}/%{name}/bios-256k.bin
-%{_datadir}/%{name}/acpi-dsdt.aml
%files system-xtensa
%defattr(644,root,root,755)
%defattr(644,root,root,755)
%attr(755,root,root) %{_libdir}/%{name}/block-curl.so
-%files module-block-dmg
-%defattr(644,root,root,755)
-%attr(755,root,root) %{_libdir}/%{name}/block-dmg-bz2.so
-
%if %{with glusterfs}
%files module-block-gluster
%defattr(644,root,root,755)
%attr(755,root,root) %{_libdir}/%{name}/block-iscsi.so
%endif
-%if %{with libnfs}
-%files module-block-nfs
-%defattr(644,root,root,755)
-%attr(755,root,root) %{_libdir}/%{name}/block-nfs.so
-%endif
-
%if %{with ceph}
%files module-block-rbd
%defattr(644,root,root,755)