diff --git a/cmd/start.go b/cmd/start.go index 02431597e..68d94491b 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -134,6 +134,7 @@ var startCmdArgs struct { Edit bool Editor string ActivateRuntime bool + Binfmt bool DNSHosts []string Foreground bool SaveConfig bool @@ -200,7 +201,7 @@ func init() { } // binfmt - startCmd.Flags().BoolVar(&startCmdArgs.Binfmt, "binfmt", true, binfmtDesc) + startCmd.Flags().BoolVar(&startCmdArgs.Flags.Binfmt, "binfmt", true, binfmtDesc) // config startCmd.Flags().BoolVarP(&startCmdArgs.Flags.Edit, "edit", "e", false, "edit the configuration file before starting") @@ -397,6 +398,7 @@ func prepareConfig(cmd *cobra.Command) { startCmdArgs.Mounts = mountsFromFlag(startCmdArgs.Flags.Mounts) startCmdArgs.Network.DNSHosts = dnsHostsFromFlag(startCmdArgs.Flags.DNSHosts) startCmdArgs.ActivateRuntime = &startCmdArgs.Flags.ActivateRuntime + startCmdArgs.Binfmt = &startCmdArgs.Flags.Binfmt // handle legacy kubernetes-disable for _, disable := range startCmdArgs.Flags.LegacyKubernetesDisable { @@ -489,6 +491,11 @@ func prepareConfig(cmd *cobra.Command) { startCmdArgs.ActivateRuntime = current.ActivateRuntime } } + if !cmd.Flag("binfmt").Changed { + if current.Binfmt != nil { + startCmdArgs.Binfmt = current.Binfmt + } + } if !cmd.Flag("network-host-addresses").Changed { startCmdArgs.Network.HostAddresses = current.Network.HostAddresses } diff --git a/config/config.go b/config/config.go index 797911fed..bebed35cd 100644 --- a/config/config.go +++ b/config/config.go @@ -46,7 +46,7 @@ type Config struct { // VM VMType string `yaml:"vmType,omitempty"` VZRosetta bool `yaml:"rosetta,omitempty"` - Binfmt bool `yaml:"binfmt,omitempty"` + Binfmt *bool `yaml:"binfmt,omitempty"` NestedVirtualization bool `yaml:"nestedVirtualization,omitempty"` DiskImage string `yaml:"diskImage,omitempty"` diff --git a/environment/vm/lima/lima.go b/environment/vm/lima/lima.go index 0e8d90cee..587a6e5c9 100644 --- a/environment/vm/lima/lima.go +++ b/environment/vm/lima/lima.go @@ -381,7 +381,7 @@ func (l *limaVM) addPostStartActions(a *cli.ActiveCommandChain, conf config.Conf a.Add(func() error { if !l.limaConf.Rosetta.Enabled { // use binfmt when rosetta is disabled and emulation is disabled i.e. host arch - if l.conf.Binfmt { + if conf.Binfmt != nil && *conf.Binfmt { if arch := environment.HostArch(); arch == environment.Arch(conf.Arch).Value() { if err := core.SetupBinfmt(l.host, l, environment.Arch(conf.Arch)); err != nil { logrus.Warn(fmt.Errorf("unable to enable qemu %s emulation: %w", arch, err))