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

Proposed by Christian Ehrhardt  on 2019-09-10
Status: Merged
Approved by: Christian Ehrhardt  on 2019-09-12
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) 2019-09-10 Approve on 2019-09-12
Canonical Server packageset reviewers 2019-09-10 Pending
Ubuntu Server Dev import team 2019-09-10 Pending
Review via email: mp+372545@code.launchpad.net
To post a comment you must log in.
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

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.

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
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
1diff --git a/debian/binfmt-update-in b/debian/binfmt-update-in
2index dd312ab..6f36024 100644
3--- a/debian/binfmt-update-in
4+++ b/debian/binfmt-update-in
5@@ -1,9 +1,8 @@
6-# check if we're running inside an (lxc) container
7-# (we may copy or move this to the postinst script too, to skip installing it)
8-grep -zqs ^container= /proc/1/environ && exit 0
9-
10 # == binfmt registration/deregistration ==
11-if command -v update-binfmts > /dev/null ; then
12+# Early exit if binfmt-support not installed or if run in a container.
13+if ! command -v update-binfmts > /dev/null || systemd-detect-virt --quiet --container; then
14+ exit 0
15+fi
16
17 fmts="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"
18
19@@ -112,5 +111,4 @@ case "$DPKG_MAINTSCRIPT_NAME:$1" in
20
21 esac
22
23-fi
24 # == binfmt registration/deregistration ==
25diff --git a/debian/changelog b/debian/changelog
26index 5530e74..fd58216 100644
27--- a/debian/changelog
28+++ b/debian/changelog
29@@ -1,3 +1,10 @@
30+qemu (1:4.0+dfsg-0ubuntu8) eoan; urgency=medium
31+
32+ * d/binfmt-update-in: fix binfmt being called in some containers
33+ (LP: #1840956)
34+
35+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Mon, 09 Sep 2019 11:03:13 +0200
36+
37 qemu (1:4.0+dfsg-0ubuntu7) eoan; urgency=medium
38
39 * No-change upload with strops.h and sys/strops.h removed in glibc.

Subscribers

People subscribed via source and target branches