@@ -15,6 +15,7 @@ import (
15
15
"syscall"
16
16
17
17
"github.com/Code-Hex/vz/v3"
18
+ "github.com/coreos/go-semver/semver"
18
19
"github.com/docker/go-units"
19
20
"github.com/lima-vm/go-qcow2reader"
20
21
"github.com/lima-vm/go-qcow2reader/image/raw"
@@ -25,6 +26,7 @@ import (
25
26
"github.com/lima-vm/lima/pkg/nativeimgutil"
26
27
"github.com/lima-vm/lima/pkg/networks"
27
28
"github.com/lima-vm/lima/pkg/networks/usernet"
29
+ "github.com/lima-vm/lima/pkg/osutil"
28
30
"github.com/lima-vm/lima/pkg/store"
29
31
"github.com/lima-vm/lima/pkg/store/filenames"
30
32
"github.com/sirupsen/logrus"
@@ -234,6 +236,27 @@ func attachPlatformConfig(driver *driver.BaseDriver, vmConfig *vz.VirtualMachine
234
236
if err != nil {
235
237
return err
236
238
}
239
+
240
+ // nested virt
241
+ if * driver .Yaml .NestedVirtualization {
242
+ macOSProductVersion , err := osutil .ProductVersion ()
243
+ if err != nil {
244
+ return fmt .Errorf ("failed to get macOS product version: %w" , err )
245
+ }
246
+
247
+ if macOSProductVersion .LessThan (* semver .New ("15.0.0" )) {
248
+ return errors .New ("nested virtualization requires macOS 15 or newer" )
249
+ }
250
+
251
+ if ! platformConfig .IsNestedVirtualizationSupported () {
252
+ return errors .New ("nested virtualization is not supported on this device" )
253
+ }
254
+
255
+ if err := platformConfig .SetNestedVirtualizationEnabled (true ); err != nil {
256
+ return fmt .Errorf ("cannot enable nested virtualization: %w" , err )
257
+ }
258
+ }
259
+
237
260
vmConfig .SetPlatformVirtualMachineConfiguration (platformConfig )
238
261
return nil
239
262
}
0 commit comments