| 1 | |
| 2 | |
| 3 | |
| 4 | package qemu |
| 5 | |
| 6 | import ( |
| 7 | "fmt" |
| 8 | "strings" |
| 9 | |
| 10 | "github.com/coreos/go-semver/semver" |
| 11 | "github.com/sirupsen/logrus" |
| 12 | |
| 13 | "github.com/lima-vm/lima/v2/pkg/limatype" |
| 14 | ) |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | func nestedVirtualizationEnabled(arch, accel, _ string, qemuVer *semver.Version) (bool, error) { |
| 22 | if arch != limatype.AARCH64 { |
| 23 | logrus.Warnf("field `nestedVirtualization` is not supported for architecture %#q, ignoring", arch) |
| 24 | return false, nil |
| 25 | } |
| 26 | if accel != "kvm" { |
| 27 | logrus.Warnf("nested virtualization is not supported with accelerator %s on this platform, ignoring", strings.ToUpper(accel)) |
| 28 | return false, nil |
| 29 | } |
| 30 | minVer := semver.New("10.1.0") |
| 31 | if qemuVer != nil && qemuVer.LessThan(*minVer) { |
| 32 | return false, fmt.Errorf("QEMU %v is too old, %v or later is required for nested virtualization with KVM", qemuVer, minVer) |
| 33 | } |
| 34 | return true, nil |
| 35 | } |