containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
22.4k stars 2.31k forks source link

user's feedback when starting a machine if rosetta is not installed #23153

Open benoitf opened 4 days ago

benoitf commented 4 days ago

Feature request description

today, if I start a podman machine without having rosetta being installed on a Apple silicon computer, I see sporadically a prompt asking me to install rosetta

But if I click no I just see 'exit 1'

podman machine start
Starting machine "withoutrosetta"
Error: vfkit exited unexpectedly with exit code 1

I would expect to see 'Rosetta is not being installed and it's not configured. Stopping'

or something more convenient for users:

  1. display that rosetta can be turned off in [machine] part of containers.conf file
  2. continue the start by saying Rosetta support is not enabled as it's not installed
  3. podman machine init could configure the machine without rosetta if it's not installed and display warnings about what we might loose/etc

Suggest potential solution

A clear and concise description of what you want to happen.

Have you considered any alternatives?

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

Julian commented 3 days ago

I'm finding this issue as well trying to figure out what has introduced the requirement for Rosetta, as this machine has never had it installed but has definitely had previous Podman machines, and now I'm unable to create one with a prompt asking for me to install Rosetta (which I don't want to do).

So, with apologies for crowding your issue, just in case anyone else finds this and wants what I want, namely "I don't need rosetta, just give me my VM", add:

[machine]
rosetta = false

to ~/.config/containers/containers.conf (which is confusingly a TOML file not INI it appears, as the error message will tell you if you write "false").

After that, podman machine init --now appears to work for me again.

And if you (future reader) does want to understand what changed, it looks like in podman 5, the default backend for machines (or provider, or whatever the podman terminology is) has changed from qemu to applehv (which appears to be a macOS native hypervisor), which I assume is what's changing things here.

I don't know / haven't read why applehv + rosetta seems to have "worse" (== more reliant behavior on Rosetta) than qemu did, I presume there's some new functionality being enabled vis a vis being able to run x86_64 things? But I don't think I need it, until I find out I do :).

EDIT: and now after searching again in closed issues I see https://github.com/containers/podman/issues/22918#issuecomment-2151517589 so there's more info there and in the linked PR.

Again sorry for my noise :)

Luap99 commented 3 days ago

@baude @ashley-cui PTAL

@cfergeau AFAIK the rosetta prompt is done by vfkit not podman so I guess this mechanism would need to be implemented there? I think having something like install rosetta yes/no and when no is selected it should just continue without it makes sense.

Of we still need to have a check in podman to print a message saying adding this to containers.conf to silence the installation prompt on each start?

Luap99 commented 3 days ago

cc @tnk4on as you added this in case you have a opinion on this

benoitf commented 3 days ago

I've checked docker desktop is also prompting people but if you click no, it proceeds and works ( just that you don't have emulation mode working) while with Podman if you say no when installing, it continues and fails

Luap99 commented 3 days ago

That way our machine image is set up if rosetta is not added it should still have qemu-user-static setup so you still have emulation just that it is slower and more buggy I guess. So yeah clicking no should be allowed and not a fatal error.

cfergeau commented 3 days ago

@baude @ashley-cui PTAL

@cfergeau AFAIK the rosetta prompt is done by vfkit not podman so I guess this mechanism would need to be implemented there? I think having something like install rosetta yes/no and when no is selected it should just continue without it makes sense.

Of we still need to have a check in podman to print a message saying adding this to containers.conf to silence the installation prompt on each start?

The rosetta installation prompt is managed by apple's virtualization framework, vfkit checks if rosetta is present, and if it's not, it calls an "install rosetta" function from the virtualization framework.

The documentation for the command line option is https://github.com/crc-org/vfkit/blob/main/doc/usage.md#rosetta

In my opinion, whether it's desirable or not to ignore rosetta being unavailable or failing to install will depend on who is using rosetta. In some cases (eg no qemu-user-static fallback), ignoring an explicit -device rosetta and successfully starting the VM even if it's not available will be undesirable. In other cases such as podman, this will be better as there is a fallback, and it's more convenient if it's vfkit which ignores rosetta rather than podman probing for rosetta availability.

A ignore-if-missing option to the rosetta device on vfkit command line could be added for podman's usecase. Instead of failing/exiting, this would print a warning and start without rosetta.

benoitf commented 2 days ago

the user experience will be better yes if we fallback to qemu if user didn't accept the install button rather than failing the startup of the podman machine.

As it seems it requires a vfkit change, should we also file an issue there ? or we still wait other feedback ?

cfergeau commented 2 days ago

As it seems it requires a vfkit change, should we also file an issue there ?

I've created https://github.com/crc-org/vfkit/issues/160

I'm not sure these vfkit changes would fully solve the issue here though, I think the user would be prompted to install rosetta every time podman machine start is used?

baude commented 2 days ago

on the podman side, we can probably handle this with a field or some such. well, to your point, we would have to ... also, it would be nice if alerted the user that if they declined, all emulation will be slower, etc. @ashley-cui thoughts on what I'm proposing?

ashley-cui commented 2 days ago

A warning sounds like a good idea, but it would be awkward to see Rosetta enabled in a machine config, but it not be actually using Rosetta. Something might need some editing there?

tnk4on commented 2 days ago

The current implementation reads the values in containers.conf at Podman machine startup and overwrites the values in machine config. The default is rosetta=true, so if you choose not to install Rosetta, there will be a conflict here. To update, this part of the process must be changed.

    rosetta := cfg.Machine.Rosetta
    rosettaNew := rosetta
    if runtime.GOARCH == "arm64" {
        rosettaMC := mc.AppleHypervisor.Vfkit.Rosetta
        if rosettaMC != rosettaNew {
            mc.AppleHypervisor.Vfkit.Rosetta = rosettaNew
        }
    }