Windows 2016 server essentials in qemu kvm on gentoo linux will not boot

kvm-virtualizationwindows

I can finish the initial installation of Windows 2016 server essentials with Qemu and libvirt on gentoo linux. But on first launch the VM will get a BSOD on first boot after installation.

Subsequent restarts display a popup window that says

"The computer restarted unexpectedly or encountered an unexpected
error. Windows installation cannot proceed. To install Windows, click
"OK" to restart the computer, and then restart the installation."

This article has the exact behavior I am experiencing except I do not get the log messages. https://gist.github.com/jorritfolmer/d01194a00f440ad257bd56d51baddc2d

I created /etc/modprobe.d/kvm.conf file and added the line:

options kvm ignore_msrs=1

but still does not work. Tried renaming to qemu.conf.
Also tried adding kvm.conf to /etc/libvirt/ and /etc/qemu/ (just a wag)

Tested with both:

  • linux 4.10.13-aufs, qemu 2.9.0-r2, libvirt 3.3.0
  • linux 4.15.14-aufs, qemu-2.11.1-r2, libvirt 4.1.0

Here is the xml

<domain type='kvm' id='1'>
  <name>WinEss</name>
  <uuid>3815d313-1a83-4f2c-9348-d5f8726ed05d</uuid>
  <memory unit='KiB'>8388608</memory>
  <currentMemory unit='KiB'>8388608</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.4'>hvm</type>
    <boot dev='cdrom'/>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <vmport state='off'/>
  </features>
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>Westmere</model>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='pclmuldq'/>
    <feature policy='require' name='x2apic'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='arat'/>
  </cpu>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/antlets/WinEss/Blank.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <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='/antlets/WinEss/antsle:volumes/WinEss.iso'/>
      <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='0x06' 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='0x06' 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='0x06' 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='0x06' 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>
    <interface type='network'>
      <mac address='b2:61:6e:73:6c:0f'/>
      <source network='bblv' bridge='virbr1'/>
      <target dev='vnet0'/>
      <model type='e1000'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target port='0'/>
      <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>
    <input type='mouse' bus='ps2'>
      <alias name='input0'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input1'/>
    </input>
    <input type='tablet' bus='usb'>
      <alias name='input2'/>
      <address type='usb' bus='0' port='1'/>
    </input>
    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <sound model='ich6'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <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='0x07' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='none' model='none'/>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+77:+77</label>
    <imagelabel>+77:+77</imagelabel>
  </seclabel>
</domain>

Update 8/10/18
I have tried changing the cpu type to core2duo and host-passthrough and all the cpu types in the cpu_map.xml
I have tried several variations with some examples from the libvirt.org documentation

<cpu match='exact'>
  <model fallback='allow'>core2duo</model>
  <vendor>Intel</vendor>
  <topology sockets='1' cores='2' threads='2'/>
  <cache level='3' mode='emulate'/>
  <feature policy='disable' name='lahf_lm'/>
</cpu>  

I did find another article recommending host-passthrough but I am not sure if I am configuring it properly in the xml.
again with several variations with and without 'feature', 'cache', 'check'… with info from libvirt.org

<cpu mode='host-passthrough' check='none'>
  <cache mode='passthrough'/>
</cpu>

<cpu mode='host-passthrough' check='none'>
  <topology sockets='1' cores='1' threads='4'/>
  <cache mode='passthrough'/>
  <feature policy='disable' name='lahf_lm'/>
</cpu>

and just

<cpu>
  <topology sockets='1' cores='1' threads='4'/>
</cpu>

Best Answer

You have to reboot after creating the file with the KVM module options.

options kvm ignore_msrs=1

Its name does not matter, as long as it is in the /etc/modprobe.d directory and ends with .conf.


You also should create your machines with Q35 machine type (never I440FX even though it's the default). I440fx is an ancient 1996-era motherboard and modern Windows doesn't really care for it.

Also you should set CPU to either core2duo or host-passthrough. Windows 10 upgrades very often fail when using any other CPU type. Use host-passthrough if you intend to run Hyper-V in the VM or you desperately need every last bit of performance; core2duo otherwise.