-
Notifications
You must be signed in to change notification settings - Fork 604
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
Support Rosetta with VZ driver #1155
Conversation
I don't have any comments on the changes other than nice work and LGTM, but do you have any suggested reading material on how this Rosetta acceleration works? Thanks. |
6f06b4a
to
0d68736
Compare
Okay, PR is updated based on feedback and I like it much better than the initial MVP. Let me know what you all think. I also rebased and moved it from draft->ready to review. |
0d68736
to
09d71fd
Compare
For how it works with Linux: https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta Rosetta in general: https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment |
pkg/vz/rosetta_directory_share.go
Outdated
) | ||
|
||
func createRosettaDirectoryShareConfiguration(install bool) (*vz.VirtioFileSystemDeviceConfiguration, error) { | ||
return nil, fmt.Errorf("Rosetta is unsupported on non-ARM64 hosts") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do a warning instead of error.
This is to make vz template runnable on both arm & x64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't users just disable Rosetta on x86 in that case? I guess this would be better UX for users so they don't have to worry about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think in that case, we probably can still return an error here, but we can turn it into a named error and check using errors.Is
in the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
pkg/vz/vm_darwin.go
Outdated
|
||
if driver.Yaml.Rosetta.Enabled { | ||
logrus.Info("Setting up Rosetta share") | ||
directorySharingDeviceConfig, err := createRosettaDirectoryShareConfiguration(driver.Yaml.Rosetta.Install) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought,
Do we needed Rosetta.Install ?
Can we directly install since Rosetta.Enabled is true already ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. I figured it would make sense to make it configurable in case users want to install Rosetta themselves. I already have it installed, so I'm not sure what it actually looks like if you try without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During installation nothing will pop-up or happen. It just like installation via command line. So i think it should be fine.
But let's also hear others opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we directly install since Rosetta.Enabled is true already ?
👍 , assuming that Enabled = true
doesn't show the macOS password popup as long as Rosetta is already installed on the macOS host.
If my assumption is untrue, probably we can't avoid having Install
property, but it has to be documented in vz.yaml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AkihiroSuda Your assumption is true. Only for installation the password pop-up will be shown. Not for every run of rosetta.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so we want to remove the install
configuration altogether. I'll rip that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated
There was also some discussion about whether or not this should be enabled by default in the other PR. What do people think? |
b53ba06
to
badcb22
Compare
The mount can be enabled by default, but binfmt should be probably opt-in for now. |
Is that best done via |
Lima itself should leave it disabled by default. The |
@AkihiroSuda Sorry I meant for Also what are your thoughts about the Rosetta installation behavior? |
Looks like installing rosetta requires the root of the macOS host, so it should be disabled by default.
|
@AkihiroSuda then it sounds like the PR as it is should be correct with the current defaults and |
7cc9272
to
9180ce9
Compare
Getting a build error on my |
5fec1fc
to
674c567
Compare
Thanks, almost looks good, but while Rosetta should be disabled by default, I assume it can be automatically installed to the macOS host when Rosetta is explicitly enabled in the YAML |
674c567
to
5162446
Compare
PR is updated to remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
pkg/vz/rosetta_directory_share.go
Outdated
@@ -0,0 +1,12 @@ | |||
//go:build darwin && !arm64 | |||
// +build darwin,!arm64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we need to use !no_vz buildtag in both rosetta files to avoid this issue
#1176
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/vz/errors.go
Outdated
@@ -0,0 +1,8 @@ | |||
//go:build darwin | |||
// +build darwin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this tags ??
errors.go can be generic irrespective of platform (We can move this https://github.com/lima-vm/lima/blob/master/pkg/vz/vz_driver_others.go#L13 as well here)
If we need this tag, then naming the file as errors_darwin.go should be sufficient and consistent across i believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without build tags the variable is detected as unused in non-darwin builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the file, and I updated build tags as more were required due to your previous comment: #1155 (comment)
Apart from those minor comments. Changes LGTM. I couldn't test install rosetta flow, as i already had it installed. |
pkg/vz/vm_darwin.go
Outdated
if errors.Is(err, errRosettaUnsupported) { | ||
logrus.Warnf("Unable to configure Rosetta: %s", err) | ||
} else if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, any error from createRosettaDirectoryShareConfiguration
can be a warning.
e.g., failure of installation of Rosetta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still unsure of this. Is there other example cases where Lima fails to do setup and continues on anyways? It seems like continuing on would lead to unexpected results for users who may not notice the warnings, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there other example cases where Lima fails to do setup and continues on anyways?
Yes, in a bunch of places (git grep -F .Warn
)
e.g.,
Line 213 in 32baa62
logrus.Warnf("DEGRADED. The VM seems running, but file sharing and port forwarding may not work. (hint: see %q)", haStderrPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. I've updated it to warn instead.
5162446
to
ad4de31
Compare
Signed-off-by: Chance Zibolski <[email protected]>
Signed-off-by: Chance Zibolski <[email protected]>
ad4de31
to
6bb3078
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Released beta.1 with Rosetta |
Useful reading: https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta
Implementation based off the sample here: https://github.com/Code-Hex/vz/tree/9de1c1041d5e560f46f9f94fc499a1cc72fd92e5/example/gui-linux