{"record":{"id":"76bfeae42505f2be","repo":"lima-vm/lima","slug":"cannot-enable-nested-virtualization-w","errorCode":null,"errorMessage":"cannot enable nested virtualization: %w","messagePattern":"cannot enable nested virtualization: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/vz/vm_darwin.go","lineNumber":368,"sourceCode":"\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get macOS product version: %w\", err)\n\t\t}\n\n\t\tif macOSProductVersion.LessThan(*semver.New(\"15.0.0\")) {\n\t\t\treturn errors.New(\"nested virtualization requires macOS 15 or newer\")\n\t\t}\n\n\t\tif !vz.IsNestedVirtualizationSupported() {\n\t\t\treturn errors.New(\"nested virtualization is not supported on this device\")\n\t\t}\n\n\t\tgenericPlatformConfig, ok := platformConfig.(*vz.GenericPlatformConfiguration)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"nested virtualization is not supported on %T\", platformConfig)\n\t\t}\n\n\t\tif err := genericPlatformConfig.SetNestedVirtualizationEnabled(true); err != nil {\n\t\t\treturn fmt.Errorf(\"cannot enable nested virtualization: %w\", err)\n\t\t}\n\t}\n\n\tvmConfig.SetPlatformVirtualMachineConfiguration(platformConfig)\n\treturn nil\n}\n\nfunc attachSerialPort(inst *limatype.Instance, config *vz.VirtualMachineConfiguration) error {\n\tpath := filepath.Join(inst.Dir, filenames.SerialVirtioLog)\n\tserialPortAttachment, err := vz.NewFileSerialPortAttachment(path, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\tconsoleConfig, err := vz.NewVirtioConsoleDeviceSerialPortConfiguration(serialPortAttachment)\n\tconfig.SetSerialPortsVirtualMachineConfiguration([]*vz.VirtioConsoleDeviceSerialPortConfiguration{\n\t\tconsoleConfig,\n\t})\n\treturn err","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/vz/vm_darwin.go#L350-L386","documentation":"When everything else passes, the driver calls genericPlatformConfig.SetNestedVirtualizationEnabled(true). If the Virtualization framework itself rejects the call, the driver wraps that error and returns it from attachPlatformConfig, failing VM creation.","triggerScenarios":"Enabling nestedVirtualization: true on macOS 15+ with reported hardware support, but VZ's SetNestedVirtualizationEnabled still fails at VM configuration time (e.g. race between capability check and set, or framework-level validation error).","commonSituations":"macOS betas or VM hosts (running Lima inside another VM) where the capability check passes but enabling fails; corrupted VZ state; running under a hypervisor that masks the feature.","solutions":["Read the wrapped %w error for the framework's underlying reason.","Upgrade macOS to the latest release to get framework fixes.","Don't run Lima inside another VM when using nested virtualization — run on bare-metal Apple Silicon.","Disable nestedVirtualization in lima.yaml if the framework cannot enable it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight: bare-metal Apple Silicon, macOS 15+\nsw_vers -productVersion   # >= 15.0.0\nsysctl -n machdep.cpu.brand_string  # Apple Silicon","typeGuard":null,"tryCatchPattern":"// Go: surface the wrapped framework error\nif err := genericPlatformConfig.SetNestedVirtualizationEnabled(true); err != nil {\n    log.Errorf(\"VZ rejected nested virtualization: %v\", err)\n    return err\n}","preventionTips":["Run on bare-metal Apple Silicon, not inside another VM","Keep macOS updated for VZ framework fixes","Read the wrapped error for the framework's exact reason","Disable nestedVirtualization if the framework cannot enable it"],"tags":["vz-driver","nested-virtualization","macos"],"backgroundTag":"nested-virtualization-unsupported","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}