@@ -17,6 +17,7 @@ import (
17
17
"time"
18
18
19
19
"github.com/lima-vm/lima/pkg/networks/usernet"
20
+ "github.com/lima-vm/lima/pkg/osutil"
20
21
21
22
"github.com/coreos/go-semver/semver"
22
23
"github.com/digitalocean/go-qemu/qmp"
@@ -398,25 +399,6 @@ func showDarwinARM64HVFQEMU620Warning(exe, accel string, features *features) {
398
399
logrus .Warn (w )
399
400
}
400
401
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
-
420
402
// adjustMemBytesDarwinARM64HVF adjusts the memory to be <= 3 GiB, only when the following conditions are met:
421
403
//
422
404
// - Host OS < macOS 12.4
@@ -443,7 +425,7 @@ func adjustMemBytesDarwinARM64HVF(memBytes int64, accel string, features *featur
443
425
if ! features .VersionGEQ7 {
444
426
return memBytes
445
427
}
446
- macOSProductVersion , err := getMacOSProductVersion ()
428
+ macOSProductVersion , err := osutil . MacOSProductVersion ()
447
429
if err != nil {
448
430
logrus .Warn (err )
449
431
return memBytes
0 commit comments