OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
apps-services low occasional DISPUTE

Enable nested virtualization so a VM can run its own VMs

omarchyarchendeavouroscachyosmanjarokvmlibvirtdesktoplaptop
CORRECTED An auditor found the fix wrong or incomplete and rewrote it.
AUDIT NOTE

Checked on this Omarchy 4 workstation (omarchy 4.0.2-1, kernel 7.1.9, Intel i9-9900K, libvirt 1:12.6.0-1, virt-manager 5.1.0-4, qemu-desktop 11.1.0-1) and against both cited wiki pages, which I fetched in full as raw wikitext. Two claims are wrong on Omarchy 4 and both were confirmed locally. First, the record's premise that nesting must be "explicitly turned on with the nested module parameter" is false: /sys/module/kvm_intel/parameters/nested reads Y on this machine with nothing in /etc/modprobe.d/ or /usr/lib/modprobe.d/ setting it (I grepped both), and mainline sets the default on for both vendors (static bool __read_mostly nested = 1; in vmx.c, static int __ro_after_init nested = true; in svm.c, both fetched from git.kernel.org). Second, the record says the "host-model CPU hides them", but virsh -c qemu:///system domcapabilities on this host reports <feature policy='require' name='vmx'/> plus 74 further vmx-* features inside the host-model block, the libvirt documentation shipped with 12.6.0 describes host-model as a copy of that same block, and the cited Arch Libvirt page itself says host-model **or** host-passthrough at its "Nested virtualization" section. So the record sends the reader through a module reload that risks their running VMs for nothing, and steers them away from the migratable CPU mode that works. Also confirmed locally: modinfo kvm_intel shows parm: nested:bool and modinfo kvm_amd shows parm: nested:int, which is why the readback differs by vendor, so the record's single "want Y" was wrong for AMD readers. check='partial' is valid per /usr/share/libvirt/schemas/cputypes.rng:31. virt-manager 5.1.0 defaults a new x86 KVM guest to host-passthrough via _get_app_default_mode in /usr/share/virt-manager/virtinst/domain/cpu.py gated on supports_safe_host_passthrough, which this host satisfies because its host-passthrough mode reports hostPassthroughMigratable values on and off. And *CPUs > Model* is still the right virt-manager path. Omarchy ships none of the virtualization stack, so I added the install step: /usr/share/omarchy/install/omarchy-base.packages matches only qemu-user-static-binfmt, and /usr/share/omarchy/bin/omarchy-update-pacman-guard aborts only when a sync and a sysupgrade flag appear together, so pacman -S --needed is safe to publish. Frequency dropped to occasional because the module parameter is on by default and virt-manager already writes host-passthrough, leaving only hand-written or imported domains. NOT exercised: I have no sudo and was told to leave libvirt alone, so I did not unload a module, did not write a modprobe file, and did not boot a guest to see vmx appear inside it. The AMD readback of 1 is inferred from the int parameter type rather than read off an AMD host, since this machine is Intel despite the orchestrator saying AMD.

The cause above was rewritten on 2026-09-11 to match this note; the fix was corrected by the audit itself.
RISK

Do not reload the KVM module unless the nested parameter actually reads off, which on a current kernel it does not. modprobe -r kvm_intel or modprobe -r kvm_amd fails while any VM is running, and killing VMs to force the unload loses unsaved guest state, so this is a real risk taken for no gain. The parameter is mode 0444, so it can be set only by reloading the module or at boot. host-passthrough copies your exact CPU to the guest, so a saved or migrated VM may refuse to resume on different hardware. host-model avoids that and still carries vmx or svm wherever the host has it.

Symptom

Inside a KVM guest, grep -Eo 'vmx|svm' /proc/cpuinfo returns nothing, ls /dev/kvm fails, and anything needing hardware virtualization in the guest refuses to run: WSL2 or Hyper-V in a Windows guest, the Android Studio emulator, Docker Desktop, or another nested VM. The outer host has KVM working perfectly.

Cause

The nested module parameter is already on for both vendors on any current kernel, so the usual cause is the guest's virtual CPU rather than the host module. Linux defaults it to enabled: arch/x86/kvm/vmx/vmx.c has static bool __read_mostly nested = 1; and arch/x86/kvm/svm/svm.c has static int __ro_after_init nested = true;. What blocks nesting is a guest CPU model that carries neither vmx nor svm. QEMU's default for a hand-written domain with no <cpu> element is qemu64, which has neither flag. Both host-model and host-passthrough carry the flag on a host that has it, because host-model is a copy of the host-model CPU definition from the host's domain capabilities XML. The module parameter is the cause only on a host where somebody turned it off or on an old kernel, and because it is mode 0444 it can be changed only by reloading the module or at boot, never through /sys.

Fix

First **read** the host parameter, because on a current kernel nesting is already on and there is nothing to change:


cat /sys/module/kvm_intel/parameters/nested     # Intel, want Y
cat /sys/module/kvm_amd/parameters/nested       # AMD, want 1 (the AMD parameter is an int, not a bool)

If it already reads Y or 1, skip to the guest CPU step. The parameter is mode 0444, so it cannot be flipped through /sys. **Only** if it reads N or 0, reload the module, with every VM shut down first because the module will not unload while one is running:


sudo modprobe -r kvm_intel && sudo modprobe kvm_intel nested=1   # Intel
sudo modprobe -r kvm_amd   && sudo modprobe kvm_amd   nested=1   # AMD

Persist it only if you actually had to change it:


printf 'options kvm_intel nested=1\n' | sudo tee /etc/modprobe.d/kvm_intel.conf   # Intel
printf 'options kvm_amd nested=1\n'   | sudo tee /etc/modprobe.d/kvm_amd.conf     # AMD

The usual real fix is the **guest's CPU mode**. A domain with no <cpu> element gets QEMU's qemu64, which carries neither vmx nor svm. Set host-model, which keeps the domain migratable, or host-passthrough:


sudo virt-xml <vm-name> --edit --cpu host-model
# or
sudo virt-xml <vm-name> --edit --cpu host-passthrough

The same thing through sudo virsh edit <vm-name>:


<cpu mode='host-model' check='partial'/>

In virt-manager the setting is *CPUs > Model*. virt-manager 5.1.0 already picks host-passthrough for a new x86 KVM guest on a host whose host-passthrough mode reports hostPassthroughMigratable, so a VM it created needs no change. With bare QEMU use -cpu host -enable-kvm.

Confirm the host really offers the flag under the mode you picked:


virsh -c qemu:///system domcapabilities | grep "name='vmx'"   # Intel
virsh -c qemu:///system domcapabilities | grep "name='svm'"   # AMD

Boot the guest and check inside it:


grep -Eo 'vmx|svm' /proc/cpuinfo | sort -u
ls -l /dev/kvm

**On Omarchy 4 none of this stack is installed.** /usr/share/omarchy/install/omarchy-base.packages carries only qemu-user-static-binfmt, which runs foreign-architecture binaries and is not a VM hypervisor. Install the host side first. The Omarchy ALPM guard aborts only when -S and -u appear in the same transaction, so a plain install is not blocked:


sudo pacman -S --needed qemu-desktop libvirt virt-manager virt-viewer dnsmasq
sudo systemctl enable --now libvirtd.socket virtlogd.socket
sudo usermod -aG libvirt "$USER"

Verify

On the host, cat /sys/module/kvm_intel/parameters/nested prints Y on Intel or cat /sys/module/kvm_amd/parameters/nested prints 1 on AMD, and virsh -c qemu:///system domcapabilities lists <feature policy='require' name='vmx'/> (or the svm equivalent) under the CPU mode the domain uses. Inside the guest, grep -Eo 'vmx|svm' /proc/cpuinfo returns the flag and /dev/kvm exists.

Sources

nested-virtualization-not-available-in-guest