Merge ~paelzer/ubuntu/+source/qemu:bug-1840956-fix-binfmt-usage-in-container-eoan into ubuntu/+source/qemu:ubuntu/eoan-devel

Proposed by Christian Ehrhardt 
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: edf43144a8bfdc9ce4a0fb48a29227d5492c155d
Merged at revision: edf43144a8bfdc9ce4a0fb48a29227d5492c155d
Proposed branch: ~paelzer/ubuntu/+source/qemu:bug-1840956-fix-binfmt-usage-in-container-eoan
Merge into: ubuntu/+source/qemu:ubuntu/eoan-devel
Diff against target: 39 lines (+11/-6)
2 files modified
debian/binfmt-update-in (+4/-6)
debian/changelog (+7/-0)
Reviewer Review Type Date Requested Status
Rafael David Tinoco (community) Approve
Canonical Server packageset reviewers Pending
git-ubuntu developers Pending
Review via email: mp+372545@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

This fixes qemu-user-static in WSL and probably other containers which were not detected by the former check.

PPA: https://launchpad.net/~paelzer/+archive/ubuntu/bug-1840956-binfmt-containers/+packages

Some considerations and tests of alternatives (and why I eventually chose this version) can be found in the updates of bug 1840956

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

I reviewed PPA contents for Eoan:

https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1840956/comments/25
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1840956/comments/26

And fix indeed works for WSL1.

Just a heads up on WSL2:

I'm not entirely sure how WSL2 binfmt_misc works there, as we currently have a /proc/sys/fs/binfmt_misc/WSLInterop right now in WSL1, and WSL2 uses a Microsoft provided kernel, and there is a feature for you to run Microsoft .exe binaries from WSL2 and app opens in Windows (I have used it and it works :o).

My point is that it might recognize WSL2 as hyperv, but, still, fail to install qemu-user-static due to binfmt_misc issues. I currently have Windows 10 Pro Insider Preview 18970.rs_prerelease.190824-1711 to try if you want, but, I'm afraid of changes for WSL2 as it is still a tech preview. There is also a way to boot WSL2 with a custom (builtin) kernel, setting up a .wslconfig file in %HOME% directory... but, again, that would not be the default for the average user.

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

I am +1 in this merge for WSL1 if you want to keep WSL2 interoperability for later (I'll be happy to assist/test/review whenever needed).

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hipervisors (KVM/Hiperv/...) are supposed to have a full kernel and work like that (e.g. binfmt_works). While containers can't really do it well.

Thanks for the checks!

The features that you are describing suggest that it will just work in WSL2.
If there is a future WSL2 which counts as !container but has issues with the registration of binfmt we'll make a new fix then.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/binfmt-update-in b/debian/binfmt-update-in
index dd312ab..6f36024 100644
--- a/debian/binfmt-update-in
+++ b/debian/binfmt-update-in
@@ -1,9 +1,8 @@
1# check if we're running inside an (lxc) container
2# (we may copy or move this to the postinst script too, to skip installing it)
3grep -zqs ^container= /proc/1/environ && exit 0
4
5# == binfmt registration/deregistration ==1# == binfmt registration/deregistration ==
6if command -v update-binfmts > /dev/null ; then2# Early exit if binfmt-support not installed or if run in a container.
3if ! command -v update-binfmts > /dev/null || systemd-detect-virt --quiet --container; then
4 exit 0
5fi
76
8fmts="aarch64 alpha arm armeb cris hppa i386 m68k microblaze mips mipsel mipsn32 mipsn32el mips64 mips64el ppc ppc64 ppc64abi32 ppc64le riscv32 riscv64 s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64 xtensa xtensaeb"7fmts="aarch64 alpha arm armeb cris hppa i386 m68k microblaze mips mipsel mipsn32 mipsn32el mips64 mips64el ppc ppc64 ppc64abi32 ppc64le riscv32 riscv64 s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64 xtensa xtensaeb"
98
@@ -112,5 +111,4 @@ case "$DPKG_MAINTSCRIPT_NAME:$1" in
112111
113esac112esac
114113
115fi
116# == binfmt registration/deregistration ==114# == binfmt registration/deregistration ==
diff --git a/debian/changelog b/debian/changelog
index 5530e74..fd58216 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
1qemu (1:4.0+dfsg-0ubuntu8) eoan; urgency=medium
2
3 * d/binfmt-update-in: fix binfmt being called in some containers
4 (LP: #1840956)
5
6 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Mon, 09 Sep 2019 11:03:13 +0200
7
1qemu (1:4.0+dfsg-0ubuntu7) eoan; urgency=medium8qemu (1:4.0+dfsg-0ubuntu7) eoan; urgency=medium
29
3 * No-change upload with strops.h and sys/strops.h removed in glibc.10 * No-change upload with strops.h and sys/strops.h removed in glibc.

Subscribers

People subscribed via source and target branches