Skip to contentSkip to conversation

linux-user: enabling binfmt P flag

Qemu-devel Riku Voipio 6 participants 24 messages Aug 25, 2014 – Sep 17, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc registration, nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get correct argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely eating one of the arguments and running regardless.

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt" string check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless they update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is very little surprise for anyone.

There will be some fallout once *distributions* change the binfmt - users will notice their existing qemu chroots stop working with a "file not found" error for any binary they try to run.

If we find even this breakage too much, I'm not sure this can be fixed.

Riku

#1 lore raw
Quoted 29 lines · Riku Voipio

Hi,

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc registration, nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get correct argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely eating one of the arguments and running regardless.

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt" string check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless they update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is very little surprise for anyone.

Quoted 5 lines

There will be some fallout once *distributions* change the binfmt - users will notice their existing qemu chroots stop working with a "file not found" error for any binary they try to run.

If we find even this breakage too much, I'm not sure this can be fixed.

I would very much prefer if we could stick with only a single binary. And yes, switching semantics when you use binfmt wrappers will hurt for a short while, but after that everyone will have their setups changed and we're safe for the future.

Alex

#2 lore raw

Alexander Graf <[email protected]> wrote on 2014/08/25 11:14:58:

Quoted 21 lines · Riku Voipio
Quoted 19 lines

Hi,

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc registration, nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get correct argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely eating one of the arguments and running regardless.

Quoted 8 lines
Quoted 8 lines

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt" string check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless they update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is

very

Quoted 3 lines
Quoted 3 lines

little surprise for anyone.

There will be some fallout once *distributions* change the binfmt -

users

Quoted 4 lines
Quoted 4 lines

will notice their existing qemu chroots stop working with a "file not found" error for any binary they try to run.

If we find even this breakage too much, I'm not sure this can be

fixed.

Quoted 5 lines

I would very much prefer if we could stick with only a single binary. And yes, switching semantics when you use binfmt wrappers will hurt for a short while, but after that everyone will have their setups changed and we're safe for the future.

Yes, but as this is going to break something whatever we do I feel it is better
move towards always requiring P flag as this how binfmt should have been impl.
from the beginning and have users switch over now.
Then ask the kernel folks for a way to explicitly see what flags are used from within linux-user so you can adapt automatically.

Jocke

#3 lore raw
In reply to Alexander Graf
Quoted 36 lines · Alexander Graf
Quoted 33 lines · Riku Voipio

Hi,

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc registration, nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get correct argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely eating one of the arguments and running regardless.

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt" string check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless they update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is very little surprise for anyone.

There will be some fallout once *distributions* change the binfmt - users will notice their existing qemu chroots stop working with a "file not found" error for any binary they try to run.

Quoted 6 lines
Quoted 1 line

If we find even this breakage too much, I'm not sure this can be fixed.

I would very much prefer if we could stick with only a single binary. And yes, switching semantics when you use binfmt wrappers will hurt for a short while, but after that everyone will have their setups changed and we're safe for the future.

I don't really the unpredictable nature of the breakage. Take

$ rm a b c
With P flag:    /bin/rm rm a b c
Without P flag: /bin/rm a b c

If we use old qemu with P flag: qemu will run /bin/rm with argv: "/bin/rm rm a b c"
-> tries to delete "rm"
If we use new qemu without P flag, qemu will run /bin/rm with argv: "a b c"
-> fails to delete "a"

This is the black magic errors that drive users nuts when they try to debug what is happening... "File not found" when the qemu binary is not in the right place is confusing enough.

Riku

#4 lore raw
Quoted 50 lines · Riku Voipio
Quoted 36 lines · Alexander Graf
Quoted 33 lines · Riku Voipio

Hi,

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc registration, nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get correct argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely eating one of the arguments and running regardless.

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt" string check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless they update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is very little surprise for anyone.

There will be some fallout once *distributions* change the binfmt - users will notice their existing qemu chroots stop working with a "file not found" error for any binary they try to run.

Quoted 6 lines
Quoted 1 line

If we find even this breakage too much, I'm not sure this can be fixed.

I would very much prefer if we could stick with only a single binary. And yes, switching semantics when you use binfmt wrappers will hurt for a short while, but after that everyone will have their setups changed and we're safe for the future.

I don't really the unpredictable nature of the breakage. Take

$ rm a b c
With P flag:    /bin/rm rm a b c
Without P flag: /bin/rm a b c
Quoted 8 lines

If we use old qemu with P flag: qemu will run /bin/rm with argv: "/bin/rm rm a b c"
-> tries to delete "rm"
If we use new qemu without P flag, qemu will run /bin/rm with argv: "a b c"
-> fails to delete "a"

This is the black magic errors that drive users nuts when they try to debug what is happening... "File not found" when the qemu binary is not in the right place is confusing enough.

Yes, but is anyone actually using the "P" flag? We've never advertised anywhere that QEMU supports it.

Maybe we should just make the next version be 3.0 and declare it a major ABI breakage ;).

Alex

#5 lore raw
Quoted 58 lines · Alexander Graf
Quoted 55 lines · Riku Voipio
Quoted 36 lines · Alexander Graf
Quoted 33 lines · Riku Voipio

Hi,

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc registration, nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get correct argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely eating one of the arguments and running regardless.

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt" string check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless they update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is very little surprise for anyone.

There will be some fallout once *distributions* change the binfmt - users will notice their existing qemu chroots stop working with a "file not found" error for any binary they try to run.

Quoted 6 lines
Quoted 1 line

If we find even this breakage too much, I'm not sure this can be fixed.

I would very much prefer if we could stick with only a single binary. And yes, switching semantics when you use binfmt wrappers will hurt for a short while, but after that everyone will have their setups changed and we're safe for the future.

I don't really the unpredictable nature of the breakage. Take

$ rm a b c
With P flag:    /bin/rm rm a b c
Without P flag: /bin/rm a b c

If we use old qemu with P flag: qemu will run /bin/rm with argv: "/bin/rm rm a b c"
-> tries to delete "rm"
If we use new qemu without P flag, qemu will run /bin/rm with argv: "a b c"
-> fails to delete "a"

Quoted 6 lines
Quoted 3 lines

This is the black magic errors that drive users nuts when they try to debug what is happening... "File not found" when the qemu binary is not in the right place is confusing enough.

Yes, but is anyone actually using the "P" flag? We've never advertised anywhere that QEMU supports it.

No, we don't use the P flag now. The changeset has not been merged in. With "new Qemu" I meant Joakims "if O assume P" patch.

Quoted 5 lines

Maybe we should just make the next version be 3.0 and declare it a major ABI breakage ;).

Alex

#6 lore raw
In reply to Alexander Graf
Quoted 68 lines · Alexander Graf
Quoted 56 lines · Riku Voipio
Quoted 36 lines · Alexander Graf
Quoted 33 lines · Riku Voipio

Hi,

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc registration, nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get correct argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely eating one of the arguments and running regardless.

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt" string check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless they update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is very little surprise for anyone.

There will be some fallout once *distributions* change the binfmt - users will notice their existing qemu chroots stop working with a "file not found" error for any binary they try to run.

Quoted 6 lines
Quoted 1 line

If we find even this breakage too much, I'm not sure this can be fixed.

I would very much prefer if we could stick with only a single binary. And yes, switching semantics when you use binfmt wrappers will hurt for a short while, but after that everyone will have their setups changed and we're safe for the future.

I don't really the unpredictable nature of the breakage. Take

$ rm a b c

With P flag: /bin/rm rm a b c
Without P flag: /bin/rm a b c

If we use old qemu with P flag: qemu will run /bin/rm with argv: "/bin/rm rm a b c"
-> tries to delete "rm"
If we use new qemu without P flag, qemu will run /bin/rm with argv: "a b c" -> fails to delete "a"

Quoted 4 lines

This is the black magic errors that drive users nuts when they try to debug what
is happening... "File not found" when the qemu binary is not in the right place is confusing enough.

Quoted 5 lines

Yes, but is anyone actually using the "P" flag? We've never advertised anywhere that QEMU supports it.

Maybe we should just make the next version be 3.0 and declare it a major ABI breakage ;).

You can also add the feature and let's the configure manages if it must be enabled or not.

Regards,
Laurent

#7 lore raw
In reply to Riku Voipio

Riku Voipio <[email protected]> wrote on 2014/08/25 14:42:57:

Quoted 7 lines · Alexander Graf
Quoted 5 lines · Riku Voipio
Quoted 2 lines

Hi,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc

registration,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get

correct

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely

eating

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

one of the arguments and running regardless.

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt"

string

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless

they

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is

very

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

little surprise for anyone.

There will be some fallout once *distributions* change the binfmt -

users

Quoted 1 line
Quoted 1 line
Quoted 1 line

will notice their existing qemu chroots stop working with a "file

not

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

found" error for any binary they try to run.

If we find even this breakage too much, I'm not sure this can be

fixed.

Quoted 3 lines
Quoted 3 lines

I would very much prefer if we could stick with only a single binary. And yes, switching semantics when you use binfmt wrappers will hurt

for

Quoted 10 lines
Quoted 2 lines

a short while, but after that everyone will have their setups changed and we're safe for the future.

I don't really the unpredictable nature of the breakage. Take

$ rm a b c
With P flag:    /bin/rm rm a b c
Without P flag: /bin/rm a b c

If we use old qemu with P flag: qemu will run /bin/rm with argv:

"/bin/rm rm a b c"

Quoted 2 lines

-> tries to delete "rm"
If we use new qemu without P flag, qemu will run /bin/rm with argv: "a b

c"

Quoted 3 lines

-> fails to delete "a"

This is the black magic errors that drive users nuts when they try to

debug what

Quoted 2 lines

is happening... "File not found" when the qemu binary is not in the right place is confusing enough.

Then consider when you run a LXC without P flag. bash expects argv0=-bash to be a
login shell and source "profile" files. This can result in even worse "black magic errors"

Either way stuff may break :(
Oh well, perhaps the binfmt wrapper is the best although then you will be stuck with the -binfmt magic handling in QEMU for a long time.

Jocke

#8 lore raw

Hi,

Quoted 1 line · Joakim Tjernlund

Then consider when you run a LXC without P flag.

Please remember that your usecase of running Qemu in LXC is a new feature, never before supported. Adding new features is always nice. However, it must not happen with expense of regressing already working features (traditional chroot).

Riku

#9 lore raw

Riku Voipio <[email protected]> wrote on 2014/08/25 15:55:55:

Quoted 7 lines

Hi,

Quoted 1 line · Joakim Tjernlund

Then consider when you run a LXC without P flag.

Please remember that your usecase of running Qemu in LXC is a new

feature,

Quoted 1 line

never before supported. Adding new features is always nice. However, it

must

Quoted 2 lines

not happen with expense of regressing already working features (traditional chroot).

OK, but traditional chroot is unaffected with my patch. Only binfmt users which uses the binfmt flag O will have to change to PO. How many is that?

Jocke

#10 lore raw
Quoted 9 lines · Joakim Tjernlund

Riku Voipio <[email protected]> wrote on 2014/08/25 15:55:55:

Quoted 7 lines

Hi,

Quoted 1 line · Joakim Tjernlund

Then consider when you run a LXC without P flag.

Please remember that your usecase of running Qemu in LXC is a new

feature,

Quoted 8 lines
Quoted 1 line

never before supported. Adding new features is always nice. However, it

must

Quoted 2 lines

not happen with expense of regressing already working features (traditional chroot).

OK, but traditional chroot is unaffected with my patch. Only binfmt users which uses the binfmt flag O will have to change to PO. How many is that?

Traditional chroot is with binfmt_misc. Debian and ubuntu packages of Qemu enable OC flags, so at least all debian/ubuntu users who use qemu linux-user in chroots are affected.

Using OC seems quite typical:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-emulation/qemu/files/qemu-binfmt.initd-r1?view=markup
http://rwmj.wordpress.com/2013/12/22/how-to-run-aarch64-binaries-on-an-x86-64-host-using-qemu-userspace-emulation/#content

Others, like Suse, scratchbox use the P flag and wrapper binary.

#11 lore raw

Riku Voipio <[email protected]> wrote on 2014/08/25 16:49:17:

Quoted 12 lines · Joakim Tjernlund
Quoted 10 lines

Riku Voipio <[email protected]> wrote on 2014/08/25 15:55:55:

Quoted 7 lines

Hi,

Quoted 1 line · Joakim Tjernlund

Then consider when you run a LXC without P flag.

Please remember that your usecase of running Qemu in LXC is a new

feature,

Quoted 1 line

never before supported. Adding new features is always nice. However,

it

Quoted 9 lines
Quoted 7 lines

must

Quoted 2 lines

not happen with expense of regressing already working features (traditional chroot).

OK, but traditional chroot is unaffected with my patch. Only binfmt users which uses the binfmt flag O will have to change to PO. How many is that?

Traditional chroot is with binfmt_misc. Debian and ubuntu packages of

Sorry, I figured you meant plain chroot

Quoted 6 lines

Qemu enable OC flags, so at least all debian/ubuntu users who use qemu linux-user in chroots are affected.

Using OC seems quite typical:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-emulation/qemu/files/qemu-binfmt.initd-r1?view=markup

Quoted 1 line

http://rwmj.wordpress.com/2013/12/22/how-to-run-aarch64-binaries-on-an-x86-64-host-using-qemu-userspace-emulation/#content

Quoted 2 lines

Others, like Suse, scratchbox use the P flag and wrapper binary.

Yes, but I meant those not using the dist. default as dists will update their binfmt scripts when upgrading QEMU.

Basically this will only be a potential problem for DIYs QEMU users.

Jocke

A message that is not in the archive (sent off-list or not yet received): OF93B0417A.866825C3-ONC1257D3F.005235F4-C1257D3F.0052A534@LocalDomain

#13 lore raw

Any resolution for how to handle P flag yet?

Jocke

Joakim Tjernlund/Transmode wrote on 2014/08/25 17:02:42:

Quoted 14 lines

Riku Voipio <[email protected]> wrote on 2014/08/25 16:49:17:

Quoted 12 lines · Joakim Tjernlund
Quoted 10 lines

Riku Voipio <[email protected]> wrote on 2014/08/25 15:55:55:

Quoted 7 lines

Hi,

Quoted 1 line · Joakim Tjernlund

Then consider when you run a LXC without P flag.

Please remember that your usecase of running Qemu in LXC is a new

feature,

Quoted 1 line

never before supported. Adding new features is always nice.

However, it

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

must

Quoted 2 lines

not happen with expense of regressing already working features (traditional chroot).

Quoted 14 lines
Quoted 5 lines
Quoted 3 lines

OK, but traditional chroot is unaffected with my patch. Only binfmt users which uses the binfmt flag O will have to change to PO. How many is that?

Traditional chroot is with binfmt_misc. Debian and ubuntu packages of

Sorry, I figured you meant plain chroot

Quoted 6 lines

Qemu enable OC flags, so at least all debian/ubuntu users who use qemu linux-user in chroots are affected.

Using OC seems quite typical:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-emulation/qemu/files/qemu-binfmt.initd-r1?view=markup

Quoted 1 line
Quoted 1 line

http://rwmj.wordpress.com/2013/12/22/how-to-run-aarch64-binaries-on-an-x86-64-host-using-qemu-userspace-emulation/#content

Quoted 9 lines
Quoted 2 lines

Others, like Suse, scratchbox use the P flag and wrapper binary.

Yes, but I meant those not using the dist. default as dists will update their binfmt scripts when upgrading QEMU.

Basically this will only be a potential problem for DIYs QEMU users.

Jocke

#14 lore raw
In reply to Riku Voipio

[cc'ing MJT for more distro opinion since I think fundamentally the choice we ought to make upstream is "what's not going to screw over distros"... Paolo, is there a RedHat QEMU maintainer who would have an opinion here?]

Quoted 27 lines · Riku Voipio

After weekend, I think the solution to using the P flag is to go back to Joakim's original patch:

http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02269.html

With this, we get:

If you continue to use qemu-x-static in your binfmt_misc registration, nothing changes - both old and new qemu work using the old binfmt registration.

If you rename the binary qemu-x-binfmt, you need to update the binfmt_misc register to have P flag and new binary - you get correct argv with new qemu. Any old qemu you still have around, will stop working. But with "file not found" error rather than obscurely eating one of the arguments and running regardless.

This leaves us with one case - people who are used to running qemu-x-static ./binary to test single binaries. Distro's will need leave a symlink from qemu-x-binfmt qemu-x-static. The "-binfmt" string check doesn't trigger, and qemu works as before.

The key point: this way nobody's working setup will break, unless they update binfmt registration. As long as the change is done by users them self (I need correct argv0 -> I will update binfmt), there is very little surprise for anyone.

Quoted 5 lines

There will be some fallout once *distributions* change the binfmt - users will notice their existing qemu chroots stop working with a "file not found" error for any binary they try to run.

If we find even this breakage too much, I'm not sure this can be fixed.

My take on this:
* I agree we can't break existing working setups with binfmt
registered with "O"
* It would be nice to have a forward path to binfmt registered
with "OP"
* The best we can do is provide a QEMU which can work in
both "O" and "OP" configurations, and clearly advertise to distros and individual users that (a) we recommend the "OP" config and binary name (b) updating the binfmt config will break any old QEMU binaries they have lying around in chroots (c) they should probably provide both binary names for back-compatibility

ie essentially leave it up to distros whether they want to move forward to the bright new "correct argv0" future at the cost of some transition pain, or if they'll just sit with their current config.

What I really would like is a way for the kernel to tell the interpreter binary what particular mangling it's chosen to do of the command line arguments. Then we could have one binary that coped in both situations and when run via the command line, and it would just come down to "recommend OP and tell people/distros to make sure to update the QEMU binaries in any chroots they have when they make that change". Unfortunately the kernel doesn't
do that and it would need a kernel change to fix it :-(

-- PMM

#15 lore raw

Peter Maydell <[email protected]> wrote on 2014/08/29 20:01:12:

.....

Quoted 10 lines

What I really would like is a way for the kernel to tell the interpreter binary what particular mangling it's chosen to do of the command line arguments. Then we could have one binary that coped in both situations and when run via the command line, and it would just come down to "recommend OP and tell people/distros to make sure to update the QEMU binaries in any chroots they have when they make that change". Unfortunately the kernel doesn't
do that and it would need a kernel change to fix it :-(

I think QEMU should request such a change, you have a good reason for it. There will be more flags in the future which will make it impossible to do the right thing automatically. I would like to see a flag which strips away the qemu-ARCH from argv, much like the other interpreters do.

Perhaps similar to AT_EXECFD? An AT_BINFMTFLAGS which holds the flags(or an empty string when no flags)

Jocke

#16 lore raw
In reply to Peter Maydell

Il 29/08/2014 20:01, Peter Maydell ha scritto:

Quoted 4 lines

[cc'ing MJT for more distro opinion since I think fundamentally the choice we ought to make upstream is "what's not going to screw over distros"... Paolo, is there a RedHat QEMU maintainer who would have an opinion here?]

There's Cole Robinson.

BTW, Fedora doesn't use the binfmt scripts from QEMU, but does reuse the binfmt lines. We'd just add Ps and we'd be fine.

However, the problem is not really for distros. Packagers just read the release notes and adjust whatever needs to be adjusted. The problem is for people who compile from source and are bit by conflicting binfmt formats from their distro.

The solution could be to extend binfmt_misc so that it sets two environment variables BINFMT_MISC_PID and BINFMT_MISC_ORIG_ARGV0. The former is set to the pid of the binfmt "interpreter" program, the latter to the argv[0] value. Then QEMU can check if BINFMT_MISC_PID matches getpid() and, if so, trust the BINFMT_MISC_ORIG_ARGV0 value.

Paolo

#17 lore raw
Quoted 9 lines · Paolo Bonzini

Il 29/08/2014 20:01, Peter Maydell ha scritto:

Quoted 4 lines

[cc'ing MJT for more distro opinion since I think fundamentally the choice we ought to make upstream is "what's not going to screw over distros"... Paolo, is there a RedHat QEMU maintainer who would have an opinion here?]

There's Cole Robinson.

BTW, Fedora doesn't use the binfmt scripts from QEMU

That's ok, nobody with any sense doesn't.

Quoted 2 lines

, but does reuse the
binfmt lines. We'd just add Ps and we'd be fine.

But this would break all your existing users' existing chroot setups. That's the question I'm after an answer to:
what do you (as a distro) think would be acceptable as transitional breakage, if anything?

Quoted 4 lines

However, the problem is not really for distros. Packagers just read the release notes and adjust whatever needs to be adjusted. The problem is for people who compile from source and are bit by conflicting binfmt formats from their distro.

This is one reason I like the "one binary name for O and one for P" approach.

Quoted 5 lines

The solution could be to extend binfmt_misc so that it sets two environment variables BINFMT_MISC_PID and BINFMT_MISC_ORIG_ARGV0. The former is set to the pid of the binfmt "interpreter" program, the latter to the argv[0] value. Then QEMU can check if BINFMT_MISC_PID matches getpid() and, if so, trust the BINFMT_MISC_ORIG_ARGV0 value.

Certainly if we're in a position to get the kernel to be more informative about how it invoked us that would be the ideal.

thanks
-- PMM

#18 lore raw

Il 01/09/2014 11:12, Peter Maydell ha scritto:

Quoted 6 lines
Quoted 1 line

We'd just add Ps and we'd be fine.

But this would break all your existing users' existing chroot setups. That's the question I'm after an answer to:
what do you (as a distro) think would be acceptable as transitional breakage, if anything?

Yes, but it's not like Fedora'd have choice. Distros have to follow what upstream does, even if it breaks something else (or they could revert the "P" patch and get an entirely specular set of bug reports).

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

The solution could be to extend binfmt_misc so that it sets two environment variables BINFMT_MISC_PID and BINFMT_MISC_ORIG_ARGV0. The former is set to the pid of the binfmt "interpreter" program, the latter to the argv[0] value. Then QEMU can check if BINFMT_MISC_PID matches getpid() and, if so, trust the BINFMT_MISC_ORIG_ARGV0 value.

Certainly if we're in a position to get the kernel to be more informative about how it invoked us that would be the ideal.

I think it's simply that "P" was ill-designed (possibly because implementing the above is not trivial).

Paolo

#19 lore raw
Quoted 11 lines · Paolo Bonzini

Il 01/09/2014 11:12, Peter Maydell ha scritto:

Quoted 6 lines
Quoted 1 line

We'd just add Ps and we'd be fine.

But this would break all your existing users' existing chroot setups. That's the question I'm after an answer to:
what do you (as a distro) think would be acceptable as transitional breakage, if anything?

Yes, but it's not like Fedora'd have choice. Distros have to follow what upstream does, even if it breaks something else (or they could revert the "P" patch and get an entirely specular set of bug reports).

Yes, that's why I'm asking what you'd prefer before we change upstream QEMU rather than just picking something randomly and letting you deal with the consequences :-)

-- PMM

#20 lore raw
In reply to Peter Maydell
Quoted 13 lines · Peter Maydell
Quoted 9 lines · Paolo Bonzini

Il 29/08/2014 20:01, Peter Maydell ha scritto:

Quoted 4 lines

[cc'ing MJT for more distro opinion since I think fundamentally the choice we ought to make upstream is "what's not going to screw over distros"... Paolo, is there a RedHat QEMU maintainer who would have an opinion here?]

There's Cole Robinson.

BTW, Fedora doesn't use the binfmt scripts from QEMU

That's ok, nobody with any sense doesn't.

Quoted 12 lines
Quoted 2 lines

, but does reuse the
binfmt lines. We'd just add Ps and we'd be fine.

But this would break all your existing users' existing chroot setups. That's the question I'm after an answer to:
what do you (as a distro) think would be acceptable as transitional breakage, if anything?

Quoted 4 lines

However, the problem is not really for distros. Packagers just read the release notes and adjust whatever needs to be adjusted. The problem is for people who compile from source and are bit by conflicting binfmt formats from their distro.

Or people with chroots from older/different distros, already having a qemu-static inside.

Quoted 2 lines

This is one reason I like the "one binary name for O and one for P" approach.

Maybe the new binary name could be something more generic than qemu-x-binfmt. Say qemu-x-user. Then distributions and users can drop the old binary name over time, and we are back to one binary again eventually.

Quoted 8 lines
Quoted 5 lines

The solution could be to extend binfmt_misc so that it sets two environment variables BINFMT_MISC_PID and BINFMT_MISC_ORIG_ARGV0. The former is set to the pid of the binfmt "interpreter" program, the latter to the argv[0] value. Then QEMU can check if BINFMT_MISC_PID matches getpid() and, if so, trust the BINFMT_MISC_ORIG_ARGV0 value.

Certainly if we're in a position to get the kernel to be more informative about how it invoked us that would be the ideal.

There is AT_FLAGS, that seems unused atm (only ever set to 0).

http://lxr.free-electrons.com/source/fs/binfmt_elf.c#L240

As indeed I afree with Paolo that (in hindsight) it was misdesign for the kernel to tell the application how it invoked us..

Riku

Riku

#21 lore raw

Riku Voipio <[email protected]> wrote on 2014/09/01 11:51:15:

Quoted 18 lines · Peter Maydell
Quoted 16 lines · Paolo Bonzini
Quoted 9 lines

Il 29/08/2014 20:01, Peter Maydell ha scritto:

Quoted 4 lines

[cc'ing MJT for more distro opinion since I think fundamentally the choice we ought to make upstream is "what's not going to screw over distros"... Paolo, is there a RedHat QEMU maintainer who would have an opinion here?]

There's Cole Robinson.

BTW, Fedora doesn't use the binfmt scripts from QEMU

That's ok, nobody with any sense doesn't.

Quoted 2 lines

, but does reuse the
binfmt lines. We'd just add Ps and we'd be fine.

Quoted 6 lines
Quoted 6 lines

But this would break all your existing users' existing chroot setups. That's the question I'm after an answer to:
what do you (as a distro) think would be acceptable as transitional breakage, if anything?

Quoted 1 line

However, the problem is not really for distros. Packagers just read

the

Quoted 1 line
Quoted 1 line
Quoted 1 line

release notes and adjust whatever needs to be adjusted. The problem

is

Quoted 10 lines
Quoted 2 lines
Quoted 2 lines

for people who compile from source and are bit by conflicting binfmt formats from their distro.

Or people with chroots from older/different distros, already having a qemu-static inside.

Quoted 2 lines

This is one reason I like the "one binary name for O and one for P" approach.

Maybe the new binary name could be something more generic than

qemu-x-binfmt.

Quoted 5 lines

Say qemu-x-user. Then distributions and users can drop the old binary name over time, and we are back to one binary again eventually.

Quoted 2 lines
Quoted 2 lines

The solution could be to extend binfmt_misc so that it sets two environment variables BINFMT_MISC_PID and BINFMT_MISC_ORIG_ARGV0.

The

Quoted 1 line
Quoted 1 line
Quoted 1 line

former is set to the pid of the binfmt "interpreter" program, the

latter

Quoted 1 line
Quoted 1 line
Quoted 1 line

to the argv[0] value. Then QEMU can check if BINFMT_MISC_PID

matches

Quoted 10 lines
Quoted 4 lines
Quoted 1 line

getpid() and, if so, trust the BINFMT_MISC_ORIG_ARGV0 value.

Certainly if we're in a position to get the kernel to be more informative about how it invoked us that would be the ideal.

There is AT_FLAGS, that seems unused atm (only ever set to 0).

http://lxr.free-electrons.com/source/fs/binfmt_elf.c#L240

As indeed I afree with Paolo that (in hindsight) it was misdesign for

the

Quoted 1 line

kernel to tell the application how it invoked us..

Did this go anywhere ? Is there a solution in sight?

Jocke

#22 lore raw
Quoted 1 line · Joakim Tjernlund

Did this go anywhere ? Is there a solution in sight?

I was hoping for more distro input, but absent that:

Does anybody care to try to float the idea of an API extension to the binfmt stuff to pass us the argv0 out-of-band (eg via an elf auxv vector entry if some new binfmt flag is passed)? That would I think be the best approach, though obviously it's a kernel change.

Failing that I'm not sure we can change upstream QEMU's behaviour because it will just break too much to do that. This sucks but the kernel as it stands just gives us no manoeuvering room :-(

thanks
-- PMM

#23 lore raw

Il 17/09/2014 18:12, Peter Maydell ha scritto:

Quoted 12 lines
Quoted 1 line · Joakim Tjernlund

Did this go anywhere ? Is there a solution in sight?

I was hoping for more distro input, but absent that:

Does anybody care to try to float the idea of an API extension to the binfmt stuff to pass us the argv0 out-of-band (eg via an elf auxv vector entry if some new binfmt flag is passed)? That would I think be the best approach, though obviously it's a kernel change.

Quoted 4 lines

Failing that I'm not sure we can change upstream QEMU's behaviour because it will just break too much to do that. This sucks but the kernel as it stands just gives us no manoeuvering room :-(

Another idea is to add a configure option that defaults to yes.

Paolo

#24 lore raw
Quoted 7 lines · Paolo Bonzini

Il 17/09/2014 18:12, Peter Maydell ha scritto:

Quoted 6 lines

Does anybody care to try to float the idea of an API extension to the binfmt stuff to pass us the argv0 out-of-band (eg via an elf auxv vector entry if some new binfmt flag is passed)? That would I think be the best approach, though obviously it's a kernel change.

Quoted 6 lines
Quoted 4 lines

Failing that I'm not sure we can change upstream QEMU's behaviour because it will just break too much to do that. This sucks but the kernel as it stands just gives us no manoeuvering room :-(

Another idea is to add a configure option that defaults to yes.

I think that still ends up breaking a bunch of people at some point in the future.

I spoke to a kernel guy this morning and he seemed vaguely positive about the idea of an API extension, so I'll see if I can find time to write and send out a patch for that.

-- PMM