From 2f0a04c6ee8c96cbc5dceedd4fb0a749a17cc3ba Mon Sep 17 00:00:00 2001 From: Shion Tanaka Date: Thu, 29 Feb 2024 02:09:20 +0900 Subject: [PATCH] Add Rosetta support for applehv(arm64) Signed-off-by: Shion Tanaka --- common/docs/containers.conf.5.md | 5 +++++ common/pkg/config/config.go | 2 ++ common/pkg/config/config_local_test.go | 11 +++++++++++ common/pkg/config/containers.conf | 5 +++++ common/pkg/config/default.go | 1 + common/pkg/config/testdata/containers_default.conf | 3 +++ 6 files changed, 27 insertions(+) diff --git a/common/docs/containers.conf.5.md b/common/docs/containers.conf.5.md index 6bfb38fec3..a14ea2145d 100644 --- a/common/docs/containers.conf.5.md +++ b/common/docs/containers.conf.5.md @@ -943,6 +943,11 @@ Virtualization provider to be used for running a podman-machine VM. Empty value is interpreted as the default provider for the current host OS. On Linux/Mac default is `QEMU` and on Windows it is `WSL`. +**rosetta**="true" + +Rosetta supports running x86_64 Linux binaries on a Podman machine on Apple silicon. +The default value is `true`. Supported on AppleHV(arm64) machines only. + ## FARMS TABLE The `farms` table contains configuration options used to group up remote connections into farms that will be used when sending out builds to different machines in a farm via `podman buildfarm`. diff --git a/common/pkg/config/config.go b/common/pkg/config/config.go index 1f5840a8ae..15c91860c1 100644 --- a/common/pkg/config/config.go +++ b/common/pkg/config/config.go @@ -663,6 +663,8 @@ type MachineConfig struct { Volumes attributedstring.Slice `toml:"volumes,omitempty"` // Provider is the virtualization provider used to run podman-machine VM Provider string `toml:"provider,omitempty"` + // Rosetta is the flag to enable Rosetta in the podman-machine VM on Apple Silicon + Rosetta bool `toml:"rosetta,omitempty"` } // FarmConfig represents the "farm" TOML config tables diff --git a/common/pkg/config/config_local_test.go b/common/pkg/config/config_local_test.go index a11d36152d..f71fee8748 100644 --- a/common/pkg/config/config_local_test.go +++ b/common/pkg/config/config_local_test.go @@ -562,4 +562,15 @@ var _ = Describe("Config Local", func() { gomega.Expect(err).To(gomega.BeNil()) gomega.Expect(config2.Machine.Memory).To(gomega.Equal(uint64(1024))) }) + It("Get Rosetta value", func() { + // Given + config, err := New(nil) + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(config.Machine.Rosetta).To(gomega.BeTrue()) + // When + config2, err := NewConfig("testdata/containers_default.conf") + // Then + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(config2.Machine.Rosetta).To(gomega.BeFalse()) + }) }) diff --git a/common/pkg/config/containers.conf b/common/pkg/config/containers.conf index f66b6cb840..22dd4713de 100644 --- a/common/pkg/config/containers.conf +++ b/common/pkg/config/containers.conf @@ -856,6 +856,11 @@ default_sysctls = [ # #provider = "" +# Rosetta supports running x86_64 Linux binaries on a Podman machine on Apple silicon. +# The default value is `true`. Supported on AppleHV(arm64) machines only. +# +#rosetta=true + # The [machine] table MUST be the last entry in this file. # (Unless another table is added) # TOML does not provide a way to end a table other than a further table being diff --git a/common/pkg/config/default.go b/common/pkg/config/default.go index aee3d4c7da..c8f34b1257 100644 --- a/common/pkg/config/default.go +++ b/common/pkg/config/default.go @@ -293,6 +293,7 @@ func defaultMachineConfig() MachineConfig { Memory: 2048, User: getDefaultMachineUser(), Volumes: attributedstring.NewSlice(getDefaultMachineVolumes()), + Rosetta: true, } } diff --git a/common/pkg/config/testdata/containers_default.conf b/common/pkg/config/testdata/containers_default.conf index 6e2c2676f1..a8315a1921 100644 --- a/common/pkg/config/testdata/containers_default.conf +++ b/common/pkg/config/testdata/containers_default.conf @@ -316,6 +316,9 @@ image = "https://example.com/$OS/$ARCH/foobar.ami" memory=1024 +# Rosetta supports running x86_64 Linux binaries on a Podman machine on Apple silicon. +# The default value is `true`. Supported on AppleHV(arm64) machines only. +rosetta=false # The [machine] table MUST be the last thing in this file. # (Unless another table is added)