<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body ><div>Can I use an installed version of Windows 7 on a real partition with virt? I wanted to get something fully working so I made a Windows 7 installation on a uefi drive last night. That way i can directly boot into windows or via virt-manager.</div><div><br></div><div>Stephen</div><div><br></div><div><br></div><div><div style="font-size:9px;color:#575757">Sent from my Verizon Wireless 4G LTE smartphone</div></div><br><br><div>-------- Original message --------</div><div>From: Alex Williamson <alex.williamson@redhat.com> </div><div>Date:03/08/2015  10:13 PM  (GMT-05:00) </div><div>To: Stephen Torri <storri@torri.org> </div><div>Cc: virt <virt@lists.fedoraproject.org> </div><div>Subject: Re: [fedora-virt] Problem assigning an NVIDIA Quadro K2000 to a   guest OS </div><div><br></div>On Sun, 2015-03-08 at 17:30 -0400, Stephen Torri wrote:<br>&gt; I followed a presentation<br>&gt; (www.linux-kvm.org/wiki/images/b/b4/2012-forum-VFIO.pdf) to try to<br>&gt; enable VGA passthrough for the guest OS. This is my first attempt at<br>&gt; using QEMU+KVM to install a guest OS. My intention is to have the guest<br>&gt; OS have direct access to the GPU for 3d gaming.<br>&gt; <br>&gt; Problem: Not sure if it is setup right. Launching the VM appears to be<br>&gt; ok. I can open windows and such but if I try to change the resolution<br>&gt; from 800x600 to something higher I get a lot garbage on the screen.<br>&gt; Moving the mouse pointer causes the background image to draw over the<br>&gt; task bar.<br>&gt; <br>&gt; My current setup:<br>&gt; <br>&gt; GPU1: NVIDIA GeForce 780 Ti (Two monitors currently connected)<br>&gt; GPU2: NVIDIA Quadro K2000 (No monitors connected)<br>&gt; - NVIDIA 346.47 properitary drivers installed.<br>&gt; - Xinerama is disabled due to possible GDM bug.<br>&gt; <br>&gt; Goal:<br>&gt; <br>&gt; (Not using VM): Linux desktop stretched across both monitors<br>&gt; (Using VM): Guest OS has full screen rendering on one montior while<br>&gt; linux is one the other.<br><br>This is not the way GPU assignment works.&nbsp; GPU assignment of Quadro<br>cards is very much like assignment of a NIC.&nbsp; When the NIC is assigned<br>to the VM, the network cable attached to the NIC is used by the VM.<br>When a GPU is assigned, the accelerated graphics channel is through the<br>video outputs of the GPU card.&nbsp; Somehow the idea of rendering into a<br>Window on the host is a common misconception.&nbsp; There is some opportunity<br>to due this, but not with Windows 7 as a guest and at a huge cost to<br>performance.&nbsp; You can of course use the input selection button on you<br>monitor to select an input channel connected to the assigned GPU.<br><br>&gt; Steps done so far:<br>&gt; 1. Used virt-manager to create a storage device on a SSD (50GB size)<br>&gt; 2. Installed Windows 7 in VM<br>&gt; 3. Updated Windows 7<br>&gt; 4. Enable virtualization support and added PCI 0000:03:00.0 as a<br>&gt; physical PCI device to the VM.<br>&gt; 5. Thinking I was not done (due to ignorance) I followed the<br>&gt; presentation I linked above to find device to assign:<br>&gt; <br>&gt; $ sudo lspci -nn | grep NVIDIA<br>&gt; 02:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK110B<br>&gt; [GeForce GTX 780 Ti] [10de:100a] (rev a1)<br>&gt; 02:00.1 Audio device [0403]: NVIDIA Corporation GK110 HDMI Audio<br>&gt; [10de:0e1a] (rev a1)<br>&gt; 03:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107GL<br>&gt; [Quadro K2000] [10de:0ffe] (rev a1)<br>&gt; 03:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio<br>&gt; Controller [10de:0e1b] (rev a1)<br>&gt; <br>&gt; 6. Worked on finding the group:<br>&gt; <br>&gt; $ sudo readlink /sys/bus/pci/devices/0000\:03\:00.0/iommu_group<br>&gt; ../../../../kernel/iommu_groups/17<br>&gt; <br>&gt; 7. Now that I have the group I worked to find the devices in the group:<br>&gt; <br>&gt; $ sudo ls /sys/bus/pci/devices/0000\:03\:00.0/iommu_group/devices<br>&gt; 0000:03:00.0&nbsp; 0000:03:00.1<br>&gt; <br>&gt; *** Ok. So two devices need to dealt with here.<br>&gt; <br>&gt; 8. I unbinded each from the device driver<br>&gt; <br>&gt; $ echo 0000:03:00.0 | sudo tee \<br>&gt; /sys/bus/pci/devices/0000:03:00.0/driver/unbind<br>&gt; <br>&gt; $ echo 0000:03:00.1 | sudo tee \<br>&gt; /sys/bus/pci/devices/0000:03:00.1/driver/unbind<br>&gt; <br>&gt; 9. Found the vendor and device ID for each:<br>&gt; <br>&gt; $ sudo lspci -n -s 03:00.0<br>&gt; 03:00.0 0300: 10de:0ffe (rev a1)<br>&gt; $ sudo lspci -n -s 03:00.1<br>&gt; 03:00.1 0403: 10de:0e1b (rev a1)<br>&gt; <br>&gt; 10. Now I bind them to vfio-pci<br>&gt; $ echo 10de 0ffe | sudo tee \<br>&gt; /sys/bus/pci/drivers/vfio-pci/new_id<br>&gt; $ echo 10de 01eb | sudo tee \<br>&gt; /sys/bus/pci/drivers/vfio-pci/new_id<br>&gt; <br>&gt; ** Not sure about this. I am not sure I have bounded them correctly.<br>&gt; <br>&gt; 11. Now checking them I see:<br>&gt; $ ls /dev/vfio<br>&gt; 17 vfio<br><br>It's good that you verified the IOMMU group only contains the GPU itself<br>and audio function, but beyond that, these steps aren't necessary.&nbsp; So<br>long as the hostdev device in your domain XML is set to managed, which<br>is the default when using virt-manager, the binding of the assigned<br>device to vfio is handled by libvirt.&nbsp; However, it's generally<br>recommended to prevent host drivers from binding to the GPU (they're not<br>as well practiced at releasing devices as NIC drivers), so we'll want to<br>configure pci-stub to claim it rather than nouveau.&nbsp; We also need to<br>deal with the audio function since it's part of the IOMMU group, so<br>we'll handle it the same way.<br><br>To do this, take the PCI vendor and device IDs that you show above and<br>add the following to your kernel commandline:<br><br>pci-stub.ids=10de:0ffe,10de:0e1b<br><br>You can do this by editing /etc/sysconfig/grub and re-running<br>grub2-mkconfig and rebooting.&nbsp; After reboot, if you run "lspci -ks 3:",<br>pci-stub should show as the driver in use for both GPU and audio<br>functions.<br><br>Now, attach a monitor to the Quadro card and you should find that when<br>the Nvidia driver is initialized in the guest, the console window in<br>virt-manager freezes (Windows7 disables that graphics controller) and<br>the monitor initializes.&nbsp; If you were to use Windows 8, the guest would<br>be able to use both the virt-manager window and the physical monitor<br>simultaneously as if it were a dual-monitor setup.&nbsp; In this mode you can<br>even get 3D graphics in the virt-manager window, but *at greatly reduced<br>performance*.&nbsp; Hope that helps,<br><br>Alex<br><br></body>