Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argv[0] can now be automatically fixed #186

Open
tvierling opened this issue Feb 23, 2023 · 0 comments
Open

argv[0] can now be automatically fixed #186

tvierling opened this issue Feb 23, 2023 · 0 comments

Comments

@tvierling
Copy link

Is this a bug report, feature (enhancement) request or question? (leave only one on its own line)

/kind enhancement

Description:

qemu-user-static can now automatically handle binfmt P mode for reflecting the correct argv[0] value, based on the name of the binary (a suffix -binfmt-P). I have a manually hacked container to do exactly this; looking into fixing it here but have to familiarize myself with this container's build automation.

Since this can now be automatic, it probably should be the default mode once implemented. There's really no reason not to use binfmt P mode if it can be used, because non-P mode is seriously buggy in many contexts.

This is fairly simple to do, if someone with more familiarity with this container's build wants to give it a go:

  1. Rename the binaries from qemu-ARCH-static to qemu-ARCH-static-binfmt-P
  2. Copy those binaries into the container, with that renaming.
  3. Change the last line of register.sh from:
    exec /qemu-binfmt-conf.sh --qemu-suffix "-static" --qemu-path "${QEMU_BIN_DIR}" $@
    to:
    exec /qemu-binfmt-conf.sh --qemu-suffix "-static-binfmt-P" --preserve-argv0 yes --qemu-path "${QEMU_BIN_DIR}" $@

Once done, argv[0] will be correct in the foreign container environment. No wrapper C program needed.

Environment:

  • QEMU version: (if you can know it): 7.2.0
  • Container application: Docker

Output of docker version, podman version or singularity version

Client:
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.17.3
 Git commit:        20.10.12-0ubuntu4
 Built:             Mon Mar  7 17:10:06 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant