When running KVM in a nested virtualization you may run into the following error when attempting to launch machines.

Example errors

qemu-system-x86_64: error: failed to set MSR 0x38d to 0x0
qemu-kvm: error: failed to set MSR 0x48e ...

What does this mean?

This error is caused by MSRs not being available to the hypervisor, in this case a virtualized hypervisor.

The Fix

To resolve this error we ignore MSRs by setting one kernel parameter, update grub, and Voilà!

Step 1:

Edit the default grub file /etc/default/grub.

Within the grub file, add kvm.ignore_msrs=1 to the GRUB_CMDLINE_LINUX constant.

It should look something like this:

GRUB_CMDLINE_LINUX="console=ttyS0 console=ttyS0,115200n81 no_timer_check  crashkernel=auto rhgb quiet kvm.ignore_msrs=1"
Step 2:

Update grub so that the new kernel parameter is automatically set on boot.

grub2-mkconfig -o "$(readlink -e /etc/grub2.conf)"

This command, or something like it, will update grub so that it stores your new default parameters.

Step 3:

At this point you can either reboot the system or simply set the parameters on the running environment. Rebooting the system is the most complete solution

Assuming you've no conflicts within the system, the following command will modify the ignore_msrs parameter, which fixes the issue and allows you to get back to work without having to perform a reboot.

echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs

If this command doesn't work due to something else locking the KVM kernel module, you can either figure out what the conflict is, or just reboot the system.

That's all folks...

MSRs, while useful, it is less useful in a nested virtualization scenario. This quick fix allows our nested stack to ignore MSRs, so we can move on with life.