Open ElDavoo opened 5 months ago
What am I missing?
The point you are missing is you can register interpreters with binfmt_misc by having them loaded into memory, using -F
(or -p
, persistent, when using QEMU's registration script). In that case, the binary is not required to exist later. So, there is a binary available when the interpreter is registered, but then any other binary running on the host or within any other container can have the instructions translated without access to a binary on the filesystem, because the functionality of such binary is available in memory until the next system restart.
This repository showcases multiples ways to register QEMU interpreters, most of them do use the -p
(persistent) option.
See section Tests of the documentation; see also https://dbhi.github.io/qus/faq.html#do-i-need-to-install-qemu-static-on-the-host-even-though-it-is-only-needed-by-the-containers. As you can see, examples f, F, c, C, v, V, r, R, s, S, h and H do register the interpreter using a binay available on the host, while examples i, I, d and D register the interpreter using a binary available on the container.
So, when your interpreter is shown as interpreter /qus/bin/qemu-x86_64-static
that means it was registered using a "qus" container and when it was run the binary existed in that location within that container; it also means it was registered persistently because, as you already guessed, that binary does not exist on the host and the container where it existed was removed.
Find further references in https://dbhi.github.io/qus/references.html, e.g. https://lwn.net/Articles/679308/ and https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=948b701a607f123df92ed29084413e5dd8cda2ed.
My ultimate goal is to use box64 instead of qemu to get more performance on my Raspi 4, so I'd like to understand how does qus register qemu
See https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh. That's the script used to register QEMU interpreters through binfmt_misc. In essence, it's just writting a magic string to /proc/sys/fs/binfmt_misc/register
(see https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh#L273-L291). Note that this repo does not use the upstream shell script, but a variant: https://github.com/umarcor/qemu/blob/series-qemu-binfmt-conf/scripts/qemu-binfmt-conf.sh; yet that should not be relevant for your goal.
Hello, I'm trying to understand how the mechanism works, but I'm stuck.
My ultimate goal is to use box64 instead of qemu to get more performance on my Raspi 4, so I'd like to understand how does qus register qemu, but I can't understand one thing.
Where is the binary?
1) It's not in the host:
2) It's not in the final emulated container:
docker image ls -a
does not show anything related to qus.I found the binary in docker internal folders:
I tried creating a container and inspecting, but no volumes are used and i couldn't see anything relevant.
So I do not understand: How does docker "apply" the
/qus/bin/qemu-x86_64-static
in the way that the binfmt_misc system can read from that path, while not apparently appearing anywhere? Because (supposedly) the kernel does not know anything about docker, so it should just try to read it from the host path (?). Or, if it tries to read it from the namespaced path, than the emulator should exist inside the container.What am I missing?
(how can I make docker use my binary (box64) to transparently run x86_64 container on arm64 like qus does?).