31.05.2022 16:45, Johannes Schauer Marin Rodrigues wrote: ..
I'm very surprised it keeps working even though the package providing the emulation binary got removed. This must mean that the qemu-user binaries are loaded into memory where they remain until reboot?
There's nothing surprising in there. This is exactly what makes your chroots working without copying qemu binaries into each chroot. This is what the "F" (fix binary) binfmt_misc flag is for. See the kernel binfmt_misc documentation, https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html . Yes, the kernel keeps the binary open since the registration of each binfmt.
I have another funny observation: the test is actually flaky and doesn't always produce the same results. I ran the same test 100 times and in 10% of the cases, qemu-user-mode emulation still worked despite the packages being removed. In 90% of the cases, foreign-arch mmdebstrap failed as I expected it to happen. Given your explanation above, I don't understand why I do not get the same result every time I run this test.
This is because you explicitly request/install binfmt-support, so it and systemd-binfmt.service are working in parallel. The result is non-deterministic. /mjt