Quoted Strings

QEMU, AMD, Intel, Windows 11 and WSL

  2024/04/07

Posted Tags: #Linux, #Windows
Other Tags: #Personal, #All

I use Arch Linux, in case you did not know that already, but I also have a two servers running Ubuntu Server LTS. What I have not talked about are the processors the various Linux distros are running on. My everyday computer running Arch Linux has an AMD Ryzen 5 5600X processor. The one server of the two I am talking about here using Ubuntu Server LTS has an Intel i5-8400. This just mattered when installing WSL in a QEMU virtual machine running Windows 11. In a previous post I mentioned that I run Arch Linux and Windows 11 in a dual boot. I used Adobe Illustrator before in a virtual machine but that was before I started using the dual boot. I wasn't going to throw away a purchased Windows key by deleting the virtual machine. But I had a virtual machine with Windows 11 installed on this server too. The reason here is running docker on Windows 11 for some use cases. Some background, I recently sold a previously owned ASRock motherboard with a SOC Denverton processor. This motherboard was hands down an excellent motherboard for a file server. But I wanted to run virtual machines too on the server and the Denverton processor just was not able to handle it. However the Intel i5-8400 also will cause VMWare's ESXI to crash during installation. An obvious reason for me to abandon ESXI on this server.

Enough background so let me get to the issue. I wanted to install WSL in a Windows 11 virtual machine on the server. Well the virtual machine was using QEMU as all mine do. As soon as I rebooted Windows 11 after enabling WSL and Virtual Machine Platform, Windows 11 blue screened at boot. I worked around and got it booted again after a Windows recovery. I have to admit Windows did a good job in this situation. I mean screwing up in Arch Linux is a whole different animal. Why do you think I wrote Strings and use rysnc for backups religiously. So I first needed to make sure virtual machine nesting was enabled on Ubuntu Server LTS. This is so I can run a virtual machine within a virtual machine. Which I was doing trying to do by running WSL in a virtual machine running Windows 11. This is the command to run in a terminal on Ubuntu Server LTS and the results you should get if nesting is enabled.

lsmod | grep -i kvm

kvm_intel             372736  0
kvm                  1032192  1 kvm_intel

Another way to check with the result is below.

cat /sys/module/kvm_intel/parameters/nested

Y

Remember I am running an Intel processor here hence the kvm_intel. Had I not gotten the above results in either case I would have used the below.

sudo su

echo "options kvm-intel nested=1" >> /etc/modprobe.d/kvm.conf

modprobe -r kvm-intel 

You may want to reboot in order to make sure nesting is working using the previous commands.

It was working for me so what was not my issue. I had nesting enabled on Arch Linux too and I tried in that Windows 11 virtual machine. It blue screen there too. So I started searching on-line for a solution. I found several in a lot of places so I tried editing QEMU XML as mentioned. In Virtual Machine Manager I needed to edit some XML which you have to enable in order to do it. In Virtual Machine Manager click to highlight the QEMU/KVM drop down and then in the Edit menu choose Preferences like below and check Enable XML Editing.

XML_editing

Then I opened the Windows 11 virtual machine and clicked on the icon for machine options. I choose CPUs and there are two tabs Details and XML. I selected XML and looked for the below:

`<cpu mode="host-passthrough" check="none" migratable="on"/>`

I made it look like the below.

<cpu mode="host-passthrough" check="none" migratable="on">
<feature policy="disable" name="hypervisor"/>
</cpu>

That worked great on my AMD machine but not on the Intel machine. I found all sorts of XML edits and tried them all but nothing worked on the Intel. I also screwed up with all the blue screens and wiped my Windows 11 install as a result. It was getting late so I purchased another Windows 11 key, installed Windows 11 and went to bed.

Got up the next day and while eating my oatmeal I searched around looking for an answer again. I found an answer to a forum question I had seen the night before but at the time I was also trying XML editing too. I had not edited any XML this time so I said what the heck try his fix without it. What did I have to lose? Here is what I did in a Terminal on the Ubuntu Server LTS server. Now remember I had nesting working, this is in addition to it.

sudo su

echo "Y" > /sys/module/kvm/parameters/ignore_msrs

echo "options kvm ignore_msrs=1" >> /etc/modprobe.d/kvm.conf

modprobe -r kvm

modprobe: FATAL: Module kvm is in use.

That last command caused an error due to the KVM module being currently in use. Everything needed to reload so I rebooted the server. After the reboot I booted Windows 11 and tried installing WSL and it worked. Rebooting Windows 11 did not blue screen.

This was all dependent on whether the processor was AMD or Intel and I had never experienced that before. I really hope this helps someone else because it drove me crazy.

Wish to add a comment? Your email address will never be shared with anyone. Please specify a user name for your comment or use anonymous.

Email me a comment to post it.