Jump to content

Windows 11 Virtual Machine Platform - WSL2 Boot Loop


Recommended Posts

I recently migrated my unraid system over to new hardware (Intel i9-13900k from old threadripper). I am trying to get WSL2 running in a windows VM and it seems every time I enable Virtual Machine Platform the VM refuses to boot and goes to Startup Repair. Frustratingly it won't give me the safe boot option or allow me to restore from a restore point so to troubleshoot my only option is to continually reinstall the OS.

 

I've tried Q35 and i440fx. I have kvm-intel.nested=1 in my syslinux config.

 

I'm at a total loss. Any ideas?

 

Here is my config:

<?xml version='1.0' encoding='UTF-8'?>
<domain type='kvm' id='8'>
  <name>matt-ws-vm</name>
  <uuid>59d27f82-1b9f-b464-d414-569246da5e34</uuid>
  <metadata>
    <vmtemplate xmlns="unraid" name="Windows 11" icon="windows11.png" os="windowstpm"/>
  </metadata>
  <memory unit='KiB'>8388608</memory>
  <currentMemory unit='KiB'>8388608</currentMemory>
  <memoryBacking>
    <nosharepages/>
  </memoryBacking>
  <vcpu placement='static'>16</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <vcpupin vcpu='2' cpuset='2'/>
    <vcpupin vcpu='3' cpuset='3'/>
    <vcpupin vcpu='4' cpuset='4'/>
    <vcpupin vcpu='5' cpuset='5'/>
    <vcpupin vcpu='6' cpuset='6'/>
    <vcpupin vcpu='7' cpuset='7'/>
    <vcpupin vcpu='8' cpuset='8'/>
    <vcpupin vcpu='9' cpuset='9'/>
    <vcpupin vcpu='10' cpuset='10'/>
    <vcpupin vcpu='11' cpuset='11'/>
    <vcpupin vcpu='12' cpuset='12'/>
    <vcpupin vcpu='13' cpuset='13'/>
    <vcpupin vcpu='14' cpuset='14'/>
    <vcpupin vcpu='15' cpuset='15'/>
  </cputune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-7.1'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi-tpm.fd</loader>
    <nvram>/etc/libvirt/qemu/nvram/59d27f82-1b9f-b464-d414-569246da5e34_VARS-pure-efi-tpm.fd</nvram>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv mode='custom'>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='none'/>
    </hyperv>
  </features>
  <cpu mode='host-passthrough' check='none' migratable='on'>
    <topology sockets='1' dies='1' cores='8' threads='2'/>
    <cache mode='passthrough'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='hypervclock' present='yes'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/local/sbin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/user/domains/matt-ws-vm/vdisk1.img' index='3'/>
      <backingStore/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <alias name='virtio-disk2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/isos/Win11_22H2_English_x64v1.iso' index='2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <boot order='2'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/isos/virtio-win-0.1.225-2.iso' index='1'/>
      <backingStore/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:73:2b:d0'/>
      <source bridge='br0'/>
      <target dev='vnet7'/>
      <model type='virtio-net'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-8-matt-ws-vm/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'>
      <alias name='input1'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input2'/>
    </input>
    <tpm model='tpm-tis'>
      <backend type='emulator' version='2.0' persistent_state='yes'/>
      <alias name='tpm0'/>
    </tpm>
    <graphics type='vnc' port='5901' autoport='yes' websocket='5701' listen='0.0.0.0' keymap='en-us'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <audio id='1' type='none'/>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+0:+100</label>
    <imagelabel>+0:+100</imagelabel>
  </seclabel>
</domain>

 

Link to comment

I have the same issue! Hyper-V does not work in both my Windows 10 and Windows 11 boxes and will cause both to not boot if installed.

Because WSL1 doesn't use Hyper-V, it will work fine, but WSL2 and Docker Desktop break my installs.

 

I've intentionally tried this on VMs that are the Unraid default for Windows 10 and 11 with the GUI drop-down for "Hyper-V" set to "Yes". So, I'm not convinced it works as intended.

Before you ask, yes, I have the kernel module installed and I have already tried adding the following line into the CPU portion of my config.

<feature policy='require' name='vmx'/>
Link to comment
  • 5 months later...
  • 1 month later...

Sorry to dig up this old thread, I've been following it for a while and was able to find a solution for my i7 12700K with the help of this thread: https://superuser.com/questions/1431148/kvm-nested-virtualbox-windows-guest/1589286#1589286

 

Try modifying this section of your XML:

 

 <cpu mode='host-passthrough' check='none' migratable='on'>
    <topology sockets='1' dies='1' cores='8' threads='2'/>
    <cache mode='passthrough'/>
  </cpu>

 

Change it to this, just be sure to keep your <topology> line the same to not change the core count:

 

  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Skylake-Client-noTSX-IBRS</model>
    <topology sockets='1' dies='1' cores='20' threads='1'/>
    <feature policy='disable' name='hypervisor'/>
    <feature policy='require' name='vmx'/>
    <feature policy='disable' name='mpx'/>
  </cpu>

 

I also had to add <feature policy='disable' name='mpx'/> which wasn't in the superuser post. I was getting an error when booting my VM so there may be some modification needed based on CPU model. With this I was able to get WSL2 working! I'm not sure if this will greatly impact performance. I'm hoping someone more knowledgeable like @SimonF may be willing to comment as I've found him to be all knowing when it comes to Unraid and VMs!

Link to comment
8 hours ago, mackid1993 said:

Sorry to dig up this old thread, I've been following it for a while and was able to find a solution for my i7 12700K with the help of this thread: https://superuser.com/questions/1431148/kvm-nested-virtualbox-windows-guest/1589286#1589286

 

Try modifying this section of your XML:

 

 <cpu mode='host-passthrough' check='none' migratable='on'>
    <topology sockets='1' dies='1' cores='8' threads='2'/>
    <cache mode='passthrough'/>
  </cpu>

 

Change it to this, just be sure to keep your <topology> line the same to not change the core count:

 

  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Skylake-Client-noTSX-IBRS</model>
    <topology sockets='1' dies='1' cores='20' threads='1'/>
    <feature policy='disable' name='hypervisor'/>
    <feature policy='require' name='vmx'/>
    <feature policy='disable' name='mpx'/>
  </cpu>

 

I also had to add <feature policy='disable' name='mpx'/> which wasn't in the superuser post. I was getting an error when booting my VM so there may be some modification needed based on CPU model. With this I was able to get WSL2 working! I'm not sure if this will greatly impact performance. I'm hoping someone more knowledgeable like @SimonF may be willing to comment as I've found him to be all knowing when it comes to Unraid and VMs!

 

This works, the VM starts, but boy the CPU is not liking it, its constant 80 to 99%

 

 

cpu.png

Edited by VladoPortos
spelling
Link to comment
17 hours ago, mackid1993 said:

Sorry to dig up this old thread, I've been following it for a while and was able to find a solution for my i7 12700K with the help of this thread: https://superuser.com/questions/1431148/kvm-nested-virtualbox-windows-guest/1589286#1589286

 

Try modifying this section of your XML:

 

 <cpu mode='host-passthrough' check='none' migratable='on'>
    <topology sockets='1' dies='1' cores='8' threads='2'/>
    <cache mode='passthrough'/>
  </cpu>

 

Change it to this, just be sure to keep your <topology> line the same to not change the core count:

 

  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Skylake-Client-noTSX-IBRS</model>
    <topology sockets='1' dies='1' cores='20' threads='1'/>
    <feature policy='disable' name='hypervisor'/>
    <feature policy='require' name='vmx'/>
    <feature policy='disable' name='mpx'/>
  </cpu>

 

I also had to add <feature policy='disable' name='mpx'/> which wasn't in the superuser post. I was getting an error when booting my VM so there may be some modification needed based on CPU model. With this I was able to get WSL2 working! I'm not sure if this will greatly impact performance. I'm hoping someone more knowledgeable like @SimonF may be willing to comment as I've found him to be all knowing when it comes to Unraid and VMs!

I would expect to see more load as the cpu is going to be emulated rather than passthru. But would need to test.

Link to comment
2 hours ago, SimonF said:

I would expect to see more load as the cpu is going to be emulated rather than passthru. But would need to test.

I'm not really seeing a difference. I also ran comparisons with Geekbench and the difference in performance seems like none. I got a lower score when using host passthrough rather than emulated which was probably just by chance. If I am correct maybe this can be something that can be added as an option in the GUI down the line. I have WSL working fine and my server is sitting at idle right now with the VM running in this configuration. I'm not home right now so it's got to be 80 degrees Farenheit in my apartment with the AC off and my CPU is sitting at 37 degrees celcius currently. From my testing I see no difference other than nested virtualization working. If there is anything I can do to help test performance let me know! 

 

Edit: Perhaps if this is a viable solution it may be helpful to make a more visible thread to help other users. I've seen a bunch of threads on this issue and it may be helpful to consolidate the discussion into one place.

Edited by mackid1993
Link to comment
  • 2 weeks later...
  • 5 months later...
  • 3 weeks later...

I recently got a Razer Blade (Razer Blade 17 _2022_ - RZ09-0423) which shipped with a 12th Gen Intel® Core™ i9-12900H × 20. Using

<model fallback='allow'>Skylake-Client-noTSX-IBRS</model>

was not going to work.

 

I ran

virsh capabilities

and learned that I have a

<model>Broadwell-noTSX-IBRS</model>

 

 

Before I installed my Windows 11 VM under KVM in Ubuntu 22.04.3, I edited the CPU XML configuration, and removed host-passthrough and manually used just this. Note: "cores=8" because the number of vCPUs allocated to my Windows 11 machine was 8. You will want these numbers to match, or Virtual Machine Manager will complain.

 

  <cpu mode="custom" match="exact" check="partial">
    <model fallback="allow">Broadwell-noTSX-IBRS</model>
    <topology sockets="1" dies="1" cores="8" threads="1"/>
    <feature policy="disable" name="hypervisor"/>
    <feature policy="require" name="vmx"/>
    <feature policy="disable" name="mpx"/>
  </cpu>

 

This worked with great success. Windows 11 installed successfully, and I got an Ubuntu WSL 2 instances running inside my WIndows 11 VM. Attempting to change the CPU XML configurations in Virtual Machine Manager AFTER installing Windows 11 was a fool's errand.

 

The performance hit may likely be remediated by appending the other CPU features as outlined in virsh capabilities.

 

EDIT:

I was able to simplify my CPU configuration to be just this:

  <cpu mode="custom" match="exact" check="partial">
    <model fallback="allow">Broadwell-noTSX-IBRS</model>
    <feature policy="require" name="vmx"/>
  </cpu>

 

Edited by RajanPatel
Link to comment
  • 2 months later...
On 2/5/2024 at 7:57 PM, RajanPatel said:

EDIT:

I was able to simplify my CPU configuration to be just this:

  <cpu mode="custom" match="exact" check="partial">
    <model fallback="allow">Broadwell-noTSX-IBRS</model>
    <feature policy="require" name="vmx"/>
  </cpu>

 

 

I used this and my Windows11 VM finally booted to finish the Ubuntu 24.04 LTS WSL installation. However, when I checked the VM definition, it seems to have auto changed this section into the following:

 

```

<cpu mode='custom' match='exact' check='full'>
  <model fallback='forbid'>Broadwell-noTSX-IBRS</model>
  <topology sockets='1' dies='1' cores='8' threads='2'/>
  <feature policy='require' name='vmx'/>
  <feature policy='require' name='vme'/>
  <feature policy='disable' name='pcid'/>
  <feature policy='require' name='f16c'/>
  <feature policy='require' name='rdrand'/>
  <feature policy='require' name='hypervisor'/>
  <feature policy='require' name='arat'/>
  <feature policy='require' name='xsaveopt'/>
  <feature policy='require' name='abm'/>
</cpu>

```

 

which seems to the be opposite of the intended effect. I'm running an Intel 13900K processor; does this have anything to do with this re-definition?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...