Windows 10 VM


ashman70

Recommended Posts

I have setup a new Windows 10 VM, I am passing through the following devices:

 

GTX 1060 3GB video card
Intel Audio
Two USB devices.

 

If I reboot my unRAID server with the VM set to auto start, it starts up and I get the display of my VM on the monitor that is connected to the DVI port on the 1060. Everything works as it should. If I do windows updates, and reboot the VM, I lose the display and the USB devices, at least the keyboard does not appear to be connected. What could be causing this?

 

<?xml version='1.0' encoding='UTF-8'?>
<domain type='kvm'>
  <name>Windows 10</name>
  <uuid>7d7e1b12-e6c4-5e98-18ae-46001b2f909e</uuid>
  <description>Gaming</description>
  <metadata>
    <vmtemplate xmlns="unraid" name="Windows 10" icon="windows.png" os="windows10"/>
  </metadata>
  <memory unit='KiB'>16777216</memory>
  <currentMemory unit='KiB'>16777216</currentMemory>
  <memoryBacking>
    <nosharepages/>
  </memoryBacking>
  <vcpu placement='static'>2</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-i440fx-5.1'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd</loader>
    <nvram>/etc/libvirt/qemu/nvram/7d7e1b12-e6c4-5e98-18ae-46001b2f909e_VARS-pure-efi.fd</nvram>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <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='2' threads='1'/>
    <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='qcow2' cache='writeback'/>
      <source file='/mnt/user/domains/Windows 10/vdisk1.img'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/isos/Windows 10/Win10_2004_English_x64.iso'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <boot order='2'/>
      <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.173-2.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <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'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:90:6c:be'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='3'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <rom file='/mnt/user/isos/1060.rom'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x1f' function='0x3'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='no'>
      <source>
        <vendor id='0x0461'/>
        <product id='0x4d22'/>
      </source>
      <address type='usb' bus='0' port='1'/>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='no'>
      <source>
        <vendor id='0x413c'/>
        <product id='0x2105'/>
      </source>
      <address type='usb' bus='0' port='2'/>
    </hostdev>
    <memballoon model='none'/>
  </devices>
</domain>

 

Link to comment
57 minutes ago, ashman70 said:

Definitely strange. Today I powered up the host, and again since the VM is set to autostart, it started and came up on the display.


As a test, I reboot the VM, and sure enough, no display on reboot.

 

Seems the only way to get the the display of the VM on the monitor is to reboot the unRAID server.

Normal for some video cards. They don't properly reset until they get a real reboot cycle, as they were never designed with VM's in mind.

 

Some cards can be forced to reset with scripts or other configuration changes, search around and see if someone else has already dealt with the reset issue for your specific card.

Link to comment

Why don't you passthrough all the components of the gpu with a proper topology (multifunction with same bus/slot different function)?you are passing through only the video and this may cause issues.

In addition you have the gpu at 01:00.0/01:00.1 (top slot?): also this may cause issues.

Edited by ghost82
Link to comment
On 9/21/2021 at 1:21 PM, ashman70 said:

How do I do this?

"passthrough all the components of the gpu with a proper topology (multifunction with same bus/slot different function)"

Sorry for delay,

you can check within unraid what components the gpu has, for example in the screen when you attach to vfio the devices.

Image from internet

image.thumb.png.4ec34b81b80fd5a5a40eb9e848367d59.png 

 

Here you can see 2 nvidia gpus, let's take into account that in iommu group 28, with 2 components: 10de:13ba, which is the video component, and 10de:0fbc, which is the audio component.

In this case the gpu has 2 components, audio and video, other gpus may have usb controllers too.

 

About multifunction, considering the example above:

the gpu video in the host (unraid) is at bus 01, slot 00, function 0 (01:00.0) --> this is the video

the gpu audio in the host (unraid) is at bus 01, slot 00, function 1 (01:00.1) --> this is the audio

 

You need to switch the configuration to advanced mode (xml view) and put that 2 components (video and audio) in the target vm with the correct topology, same bus, same slot different function.

This will be the correct xml:

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0' multifunction='on'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
    </hostdev>

 

Explanation:

1. the first block inside <hostdev></hostdev> is the video part

1.a inside the <source></source> block you will find the address of the video component in the host (unraid) --> 01:00.0

1.b <address /> block is where you put the gpu video component in the target (the virtual machine): in this case it was set to 03:00.0 (bus=03, slot=00, function 0) --> note that you can change a bus number different than 03, just a set a free one

1.c inside <address /> it was added multifunction='on', because the gpu is a multifunction device (it has different components in the same bus and in the same slot)

 

2. the second block inside <hostdev></hostdev> is the audio part

2.a inside the <source></source> block you will find the address of the audio component in the host (unraid) --> 01:00.1

3.b <address /> block is where you put the gpu audio component in the target (the virtual machine): in this case it was set to 03:00.1 (bus=03, slot=00, function 1) --> note that you can change a bus number different than 03, this must be the same as the video component

 

Summary:

In the host unraid: video at 01:00.0, audio at 01:00.1

In the vm: video at 03:00.0, audio at 03:00.1

 

You can see that now in the vm you have a proper topology, same bus, same slot, different function.

 

Note: this is for a q35 type emulated machine, where you have buses different than 0 too.

For a i440fx you have only bus 0 in the vm, but the same applies, just set bus to 0x00 for both video and audio and respect the other rules (same bus=0, same slot, different function.

 

This is an example of wrong configuration (this will result from setting the vm from the unraid gui) - q35 machine:

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </hostdev>

 

Unraid doesn't take into account the multifunction and set the video on one bus and the audio on a different bus, and this may cause issues.

In this wrong case:

In the host unraid: video at 01:00.0, audio at 01:00.1

In the vm: video at 03:00.0, audio at 04:00.0

Edited by ghost82
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.