Quantcast
Channel: Ubuntu Forums - Virtualisation
Viewing all articles
Browse latest Browse all 4211

[xubuntu] Switchable Graphic Passthrough with KVM

$
0
0
Greetings!

Howdy to you all from this new member of the forum, and a new convert to Linux! :)..

After researching for a while, I am very much interested in KVM, especially since it allows to pass through hardware to client OSs (also one of the reason why I convert..) Anyways, as the title suggests, I am trying to pass a GPU to Windows 10 client but unfortunately with no success.

I have a Lenovo G510 laptop with the following configuration:
  • CPU Intel i7 4800MQ (upgraded from i7 4700MQ to support VT-d)
  • Switchable graphics with:
    • Integrated Graphics - Intel HD Graphics 4600
    • Dedicated Graphics - AMD Radeon HD 8750M

  • Xubuntu 16.04


My /etc/modules looks like:
Code:

pci_stubvfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
kvm
kvm_intel
...

My GRUB setting looks like:
Code:

quiet splash radeon.modeset=1 i915.modeset=1 radeon.runpm=0 intel_iommu=on vfio_iommu_type1.allow_unsafe_interrupts=1
My /etc/modprobe.d/vfio.conf looks like:
Code:

options vfio-pci ids=1002:6600
I added
Code:

blacklist radeon
to my /etc/modprobe.d/blacklist.conf.

Not to forget the following steps:
Code:

echo '0000:01:00.0' | sudo tee /sys/bus/pci/devices/0000:01:00.0/driver/unbind    sudo modprobe vfio
    sudo modprobe vfio_pci
    echo 1002 6600 | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id

And, after running sudo update-initramfs -u, dmesg | grep vfio looks like
Code:

...
[    5.344080] vfio_pci: add [1002:6600[ffff:ffff]] class 0x000000/00000000
...

And sudo lspci -vv shows
Code:

...
01:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Mars [Radeon HD 8670A/8670M/8750M]
...
Kernel driver in use: vfio-pci
Kernel modules: radeon

...

The following is my QEMU script to my Windows 10 client #1:
Code:

sudo qemu-system-x86_64 -enable-kvm -M q35 -m 8192 -cpu host,kvm=off -smp 4,sockets=1,cores=4,threads=1 -vga std -soundhw pcspk -usb -usbdevice tablet -device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 -device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=off,rombar=0 -drive file=/home/lolla/boxes/iobox.img,id=disk,format=raw,if=virtio -drive file=/home/lolla/Download/Win10_1511_1_EnglishInternational_x64.iso,id=isocd,format=raw,if=none -device ide-cd,bus=ide.1,drive=isocd -cdrom /home/lolla/Download/virtio-win-0.1.102.iso -boot menu=on;
The following is my XML configuration for my WIndows 10 client #2:
Code:

<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh edit iobox
or other application using the libvirt API.
-->


<domain type='kvm'>
  <name>iobox</name>
  <uuid>2251c26e-0a29-4652-91e9-1657c04e3ec3</uuid>
  <memory unit='KiB'>8388608</memory>
  <currentMemory unit='KiB'>8388608</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <os>
    <type arch='x86_64' machine='pc-q35-2.5'>hvm</type>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
  </features>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>Haswell-noTSX</model>
    <topology sockets='4' cores='1' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
  </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='cdrom'>
      <driver name='qemu' type='raw' io='native'/>
      <target dev='sda' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw' io='native'/>
      <target dev='sdb' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' io='native'/>
      <source file='/var/lib/libvirt/images/iobox.img'/>
      <target dev='vda' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x2'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
      <model name='i82801b11-bridge'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
    </controller>
    <controller type='pci' index='2' model='pci-bridge'>
      <model name='pci-bridge'/>
      <target chassisNr='2'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='51:53:00:1c:14:0b'/>
      <source network='default'/>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='spice' autoport='yes'>
      <image compression='off'/>
    </graphics>
    <sound model='ich9'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
    </sound>
    <video>
      <model type='vga' vram='16384' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <rom bar='off'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/>
    </hostdev>
    <redirdev bus='usb' type='spicevmc'>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
    </redirdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
</domain>

Both of these VMs recognize the AMD Radeon, as Graphic Device, but only with Error Code 43.

I tried these and those, I even use a customized kernel, just to enable DMA remapping option, which in default kernel was disabled. Am I missing something? Do my hardware support passthrough? Is there someway I can do to check (both in host or in clients) if everything is OK? Does it have any connection to vgaswitcheroo because of the switchable graphics? If so, using my modified kernel, I get the following error:

Code:

sudo ls -l /sys/kernel/debug/vgaswitcheroo/switch
ls: cannot access '/sys/kernel/debug/vgaswitcheroo/switch': No such file or directory

I appreciate all help and guidance. Any further online resources will also be a great help. Many thanks!

Cheers!

Viewing all articles
Browse latest Browse all 4211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>