-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Rosetta with vmType: vz
Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
- Loading branch information
Showing
9 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
if [ "$LIMA_CIDATA_ROSETTA_ENABLED" != "true" ]; then | ||
exit 0 | ||
fi | ||
|
||
mkdir -p /mnt/lima-rosetta | ||
mount -t virtiofs vz-rosetta /mnt/lima-rosetta | ||
|
||
if [ "$LIMA_CIDATA_ROSETTA_BINFMT" = "true" ]; then | ||
echo \ | ||
':rosetta:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/mnt/lima-rosetta/rosetta:OCF' \ | ||
>/proc/sys/fs/binfmt_misc/register | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:build darwin && !arm64 | ||
// +build darwin,!arm64 | ||
|
||
package vz | ||
|
||
import ( | ||
"github.com/Code-Hex/vz/v3" | ||
) | ||
|
||
func createRosettaDirectoryShareConfiguration(install bool) (*vz.VirtioFileSystemDeviceConfiguration, error) { | ||
return nil, errRosettaUnsupported | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//go:build darwin && arm64 | ||
// +build darwin,arm64 | ||
|
||
package vz | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Code-Hex/vz/v3" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func createRosettaDirectoryShareConfiguration(install bool) (*vz.VirtioFileSystemDeviceConfiguration, error) { | ||
config, err := vz.NewVirtioFileSystemDeviceConfiguration("vz-rosetta") | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create a new virtio file system configuration: %w", err) | ||
} | ||
availability := vz.LinuxRosettaDirectoryShareAvailability() | ||
switch availability { | ||
case vz.LinuxRosettaAvailabilityNotSupported: | ||
return nil, errRosettaUnsupported | ||
case vz.LinuxRosettaAvailabilityNotInstalled: | ||
if !install { | ||
return nil, fmt.Errorf("Rosetta is not installed") | ||
} | ||
logrus.Info("Installing rosetta...") | ||
if err := vz.LinuxRosettaDirectoryShareInstallRosetta(); err != nil { | ||
return nil, fmt.Errorf("failed to install rosetta: %w", err) | ||
} | ||
logrus.Info("Rosetta installation complete.") | ||
case vz.LinuxRosettaAvailabilityInstalled: | ||
// nothing to do | ||
} | ||
|
||
rosettaShare, err := vz.NewLinuxRosettaDirectoryShare() | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create a new rosetta directory share: %w", err) | ||
} | ||
config.SetDirectoryShare(rosettaShare) | ||
|
||
return config, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters