@@ -17,6 +17,7 @@ import (
1717 "time"
1818
1919 "github.com/lima-vm/lima/pkg/networks/usernet"
20+ "github.com/lima-vm/lima/pkg/osutil"
2021
2122 "github.com/coreos/go-semver/semver"
2223 "github.com/digitalocean/go-qemu/qmp"
@@ -398,25 +399,6 @@ func showDarwinARM64HVFQEMU620Warning(exe, accel string, features *features) {
398399 logrus .Warn (w )
399400}
400401
401- func getMacOSProductVersion () (* semver.Version , error ) {
402- cmd := exec .Command ("sw_vers" , "-productVersion" )
403- // output is like "12.3.1\n"
404- b , err := cmd .Output ()
405- if err != nil {
406- return nil , fmt .Errorf ("failed to execute %v: %w" , cmd .Args , err )
407- }
408- verTrimmed := strings .TrimSpace (string (b ))
409- // macOS 12.4 returns just "12.4\n"
410- for strings .Count (verTrimmed , "." ) < 2 {
411- verTrimmed += ".0"
412- }
413- verSem , err := semver .NewVersion (verTrimmed )
414- if err != nil {
415- return nil , fmt .Errorf ("failed to parse macOS version %q: %w" , verTrimmed , err )
416- }
417- return verSem , nil
418- }
419-
420402// adjustMemBytesDarwinARM64HVF adjusts the memory to be <= 3 GiB, only when the following conditions are met:
421403//
422404// - Host OS < macOS 12.4
@@ -443,7 +425,7 @@ func adjustMemBytesDarwinARM64HVF(memBytes int64, accel string, features *featur
443425 if ! features .VersionGEQ7 {
444426 return memBytes
445427 }
446- macOSProductVersion , err := getMacOSProductVersion ()
428+ macOSProductVersion , err := osutil . MacOSProductVersion ()
447429 if err != nil {
448430 logrus .Warn (err )
449431 return memBytes
0 commit comments