qemu: support nestedVirtualization with HVF (QEMU 11.1 or later) - #5443
qemu: support nestedVirtualization with HVF (QEMU 11.1 or later)#5443sharanrajt wants to merge 1 commit into
nestedVirtualization with HVF (QEMU 11.1 or later)#5443Conversation
| case limatype.ARMV7L: | ||
| machine := "virt,accel=" + accel | ||
| if y.NestedVirtualization != nil && *y.NestedVirtualization { | ||
| machine += ",virtualization=on" |
There was a problem hiding this comment.
How did you test this configuration?
There was a problem hiding this comment.
I didn't test it. I added it because the virt machine accepts virtualization=on for 32-bit too. But armv7l guests aretcg-only in Lima and Linux dropped kvm on 32-bit ARM hosts in 5.7, so a guest couldn't use it anyway. I'll remove the armv7l case and keep this PR to aarch64.
| } | ||
| } | ||
|
|
||
| if cfg.NestedVirtualization != nil && *cfg.NestedVirtualization { |
There was a problem hiding this comment.
Can we support Linux hosts?
There was a problem hiding this comment.
Yes. For aarch64 the same code path applies on Linux/KVM, the macOS version check is darwin-only, and virtualization=on works with KVM given QEMU ≥ 10.1 and a ≥ 6.16 host kernel booted with kvm-arm.mode=nested (FEAT_NV hardware); otherwise QEMU fails with a clear "host kernel KVM does not support providing Virtualization extensions" error. I don't have such hardware, so this part is untested.
For x86_64/KVM, nested virt is a host-side setting exposed through -cpu host, which Lima already uses. I'll change the x86_64 path to check /sys/module/kvm_{intel,amd}/parameters/nested and error only when it's disabled, instead of warning "unsupported". I'll also document the Linux requirements in default.yaml.
QEMU 11.1 added nested virtualization support to the HVF accelerator for the aarch64 `virt` machine (https://wiki.qemu.org/ChangeLog/11.1). Enable it by passing `virtualization=on` to the `virt` machine when `nestedVirtualization: true`. With HVF, require QEMU 11.1.0 or later and macOS 15 or later (QEMU relies on `hv_vm_config_set_el2_enabled`). The field is ignored with a warning for architectures other than aarch64 and armv7l. Tested on Apple M4 / macOS 26.5 with QEMU 11.1.0: the guest kernel initializes KVM in nVHE mode and a nested KVM VM boots EDK2 to the UEFI shell. Fix lima-vm#5419 Signed-off-by: Sharan Raj T <sharanrajtm@gmail.com>
5a7cdd9 to
1b74646
Compare
What This PR Changes
QEMU 11.1 added nested virtualization support to the HVF accelerator for the aarch64
virtmachine (https://wiki.qemu.org/ChangeLog/11.1).This PR adds support for nested virtualization in the QEMU driver:
virtualization=onto thevirtmachine (-machine virt,...,virtualization=on) foraarch64andarmv7lwhennestedVirtualization: true.hvfaccelerator (since QEMU relies on macOS 15'shv_vm_config_set_el2_enabled).nestedVirtualizationfor architectures other thanaarch64andarmv7l.templates/default.yamlcomments to documentvmType: qemusupport on Apple M3+ / macOS 15+.Linked Issue (Required in most cases)
Closes #5419
How I Tested This
TestValidateConfigNestedVirtualizationtopkg/driver/qemu/qemu_test.goand rango test -v ./pkg/driver/qemu/....make minimaland verifiedgo test ./....AI Usage
Assisted-by: Antigravity