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

Cannot install qemu-user-static #2103

Closed
stellirin opened this issue May 14, 2017 · 14 comments
Closed

Cannot install qemu-user-static #2103

stellirin opened this issue May 14, 2017 · 14 comments

Comments

@stellirin
Copy link

This is installed as part of building armbian, used as part of the chroot to build a root file system for an ARMv7 device.

  • Your Windows build number: (Type ver at a Windows Command Prompt)
$ uname -a
Linux afa-pc 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux
> systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.15063 N/A Build 15063
  • What you're doing and what's happening: (Copy&paste specific commands and their output, or include screen shots)
$ sudo apt-get install qemu-user-static
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed
  qemu-user-static
0 to upgrade, 1 to newly install, 0 to remove and 48 not to upgrade.
Need to get 0 B/7,357 kB of archives.
After this operation, 85.8 MB of additional disk space will be used.
Selecting previously unselected package qemu-user-static.
(Reading database ... 41642 files and directories currently installed.)
Preparing to unpack .../qemu-user-static_1%3a2.5+dfsg-5ubuntu10.11_amd64.deb ...
Unpacking qemu-user-static (1:2.5+dfsg-5ubuntu10.11) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up qemu-user-static (1:2.5+dfsg-5ubuntu10.11) ...
update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: Invalid argument
update-binfmts: warning: unable to enable binary format qemu-aarch64
update-binfmts: exiting due to previous errors
dpkg: error processing package qemu-user-static (--configure):
 subprocess installed post-installation script returned error exit status 2
E: Sub-process /usr/bin/dpkg returned an error code (1)
@stellirin
Copy link
Author

I see in the closing of #668 that the binfmt_misc filesystem was implemented, but it seems something was missed?

@sunjoong
Copy link

sunjoong commented May 14, 2017

@AdFad666 - I don't know this is relevant, but found this;

SUNJOONG-DESKTOP sunjoong # cd /proc/sys/fs/binfmt_misc/
SUNJOONG-DESKTOP binfmt_misc # ls -l
total 0
-rw-r--r-- 1 root root 0  5월 15 08:00 WSLInterop
--w------- 1 root root 0  5월 15 07:57 register
-rw-r--r-- 1 root root 0  5월 15 07:57 status
SUNJOONG-DESKTOP binfmt_misc # chmod u+r register
SUNJOONG-DESKTOP binfmt_misc # cat register
cat: register: Operation not permitted
SUNJOONG-DESKTOP binfmt_misc # whoami
root
SUNJOONG-DESKTOP binfmt_misc #

@stellirin
Copy link
Author

@sunjoong Compared to my 'real' Linux box, that appears to be correct.

@benhillis benhillis added the bug label Jul 22, 2017
@benhillis benhillis self-assigned this Jul 22, 2017
@benhillis
Copy link
Member

I'm looking at this issue currently, our binfmt interpreter does not support the flags qemu is using.

@benhillis
Copy link
Member

I have a change in code review that adds support for binfmt_misc flags. This change will be available in an Insider build soon and will ship with Fall Creators Update.

https://www.kernel.org/doc/Documentation/admin-guide/binfmt-misc.rst

  ``P`` - preserve-argv[0]
        Legacy behavior of binfmt_misc is to overwrite
        the original argv[0] with the full path to the binary. When this
        flag is included, binfmt_misc will add an argument to the argument
        vector for this purpose, thus preserving the original ``argv[0]``.
        e.g. If your interp is set to ``/bin/foo`` and you run ``blah``
        (which is in ``/usr/local/bin``), then the kernel will execute
        ``/bin/foo`` with ``argv[]`` set to ``["/bin/foo", "/usr/local/bin/blah", "blah"]``.  The interp has to be aware of this so it can
        execute ``/usr/local/bin/blah``
        with ``argv[]`` set to ``["blah"]``.
  ``O`` - open-binary
    Legacy behavior of binfmt_misc is to pass the full path
        of the binary to the interpreter as an argument. When this flag is
        included, binfmt_misc will open the file for reading and pass its
        descriptor as an argument, instead of the full path, thus allowing
        the interpreter to execute non-readable binaries. This feature
        should be used with care - the interpreter has to be trusted not to
        emit the contents of the non-readable binary.
  ``C`` - credentials
        Currently, the behavior of binfmt_misc is to calculate
        the credentials and security token of the new process according to
        the interpreter. When this flag is included, these attributes are
        calculated according to the binary. It also implies the ``O`` flag.
        This feature should be used with care as the interpreter
        will run with root permissions when a setuid binary owned by root
        is run with binfmt_misc.

@sunilmut
Copy link
Member

This is fixed in Fall Creators Update and any build > 16273.

@131
Copy link

131 commented Nov 12, 2017

I got a qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Microsoft Windows [version 10.0.16299.19]

ii  qemu-user-static                 1:2.5+dfsg-5ubuntu10.16 

root@acsfrlt-j8shv32:/tmp/ivs-ghost-rpi23# uname -a
Linux acsfrlt-j8shv32 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux

How can i retrieve the core dump ?

@lilyanatia
Copy link

I'm having this same issue on build 18362:

> ver
Microsoft Windows [Version 10.0.18362.295]
$ sudo apt install qemu-user-static
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  qemu-user-static
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/21.1 MB of archives.
After this operation, 211 MB of additional disk space will be used.
Selecting previously unselected package qemu-user-static.
(Reading database ... 46148 files and directories currently installed.)
Preparing to unpack .../qemu-user-static_1%3a3.1+dfsg-8~deb10u1_amd64.deb ...
Unpacking qemu-user-static (1:3.1+dfsg-8~deb10u1) ...
Setting up qemu-user-static (1:3.1+dfsg-8~deb10u1) ...
update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: Invalid argument
update-binfmts: warning: unable to enable binary format qemu-aarch64
update-binfmts: exiting due to previous errors
dpkg: error processing package qemu-user-static (--configure):
 installed qemu-user-static package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 qemu-user-static
E: Sub-process /usr/bin/dpkg returned an error code (1)

@mingqian
Copy link

mingqian commented Sep 24, 2019

Have the same issue with:
[OS]
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.17763 N/A Build 17763

[distro]
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

when sudo apt-get install qemu-user-static:
Setting up qemu-user-static (1:3.1+dfsg-8+deb10u2) ...
update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: Invalid argument
update-binfmts: warning: unable to enable binary format qemu-aarch64
update-binfmts: exiting due to previous errors
dpkg: error processing package qemu-user-static (--configure):
installed qemu-user-static package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
qemu-user-static
E: Sub-process /usr/bin/dpkg returned an error code (1)

@hict-nvdael
Copy link

Have the same issue with:
[OS]
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.17763 N/A Build 17763

[distro]
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

when sudo apt-get install qemu-user-static:
Setting up qemu-user-static (1:3.1+dfsg-8+deb10u2) ...
update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: Invalid argument
update-binfmts: warning: unable to enable binary format qemu-aarch64
update-binfmts: exiting due to previous errors
dpkg: error processing package qemu-user-static (--configure):
installed qemu-user-static package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
qemu-user-static
E: Sub-process /usr/bin/dpkg returned an error code (1)

same here

@mforkel
Copy link

mforkel commented Dec 27, 2019

May be this is not WSL's fault. According to Ubuntu Bug #1840956, the maintainer scripts do not recognize WSL as a container. The patch in qemu 1:3.1+dfsg-2ubuntu3.5 worked for me in Windows 10 Pro Build 18363.535 with WSL Debian. allows to configure the package. But it suppresses the installation of the binary formats.

With the value no for option --fix-binary of update-binfmts in the maintainer script qemu-user-static.postinst, all binary formats of qemu-user-static were successfully installed in WSL Debian Buster on Windows 10 Pro Build 18363.535.

@mwpowellhtx
Copy link

mwpowellhtx commented Apr 14, 2020

Hello, running from a guest VM, OS Ubuntu 18 LTS. My goal is to do some R-Pi emulation using qemu and so forth. How critical is it that I need a working sudo apt install qemu-user-static? Because today, it seems at least that the LTS package sources do not include this.

Edit: Not entirely confident, but this seems to have been the trick, sudo apt-get install qemu qemu-user-static binfmt-support.

@MartinEmrich
Copy link

For anyone having this issue with Debian 12 Bookworm on WSL2: the Postinst script seems to not register the binaries on WSL2.
Doing this manually seems to work:

for fmt in aarch64 alpha arm armeb cris hexagon hppa loongarch64 m68k microblaze mips mipsel mipsn32 mipsn32el mips64 mips64el ppc ppc64 ppc64le riscv32 riscv64 s390x sh4 sh4eb sparc sparc32plus sparc64 xtensa xtensaeb; do 
        sudo update-binfmts --import qemu-$fmt;   
done

@lud0v1c
Copy link

lud0v1c commented Jul 30, 2024

For anyone having this issue with Debian 12 Bookworm on WSL2: the Postinst script seems to not register the binaries on WSL2. Doing this manually seems to work:

for fmt in aarch64 alpha arm armeb cris hexagon hppa loongarch64 m68k microblaze mips mipsel mipsn32 mipsn32el mips64 mips64el ppc ppc64 ppc64le riscv32 riscv64 s390x sh4 sh4eb sparc sparc32plus sparc64 xtensa xtensaeb; do 
        sudo update-binfmts --import qemu-$fmt;   
done

Saved my multiarch CI builds, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests