<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>> I followed a presentation<br>> (www.linux-kvm.org/wiki/images/b/b4/2012-forum-VFIO.pdf) to try to<br>> enable VGA passthrough for the guest OS. This is my first attempt at<br>> using QEMU+KVM to install a guest OS. My intention is to have the guest<br>> OS have direct access to the GPU for 3d gaming.<br>> <br>> Problem: Not sure if it is setup right. Launching the VM appears to be<br>> ok. I can open windows and such but if I try to change the resolution<br>> from 800x600 to something higher I get a lot garbage on the screen.<br>> Moving the mouse pointer causes the background image to draw over the<br>> task bar.<br>> <br>> My current setup:<br>> <br>> GPU1: NVIDIA GeForce 780 Ti (Two monitors currently connected)<br>> GPU2: NVIDIA Quadro K2000 (No monitors connected)<br>> - NVIDIA 346.47 properitary drivers installed.<br>> - Xinerama is disabled due to possible GDM bug.<br>> <br>> Goal:<br>> <br>> (Not using VM): Linux desktop stretched across both monitors<br>> (Using VM): Guest OS has full screen rendering on one montior while<br>> linux is one the other.<br><br>This is not the way GPU assignment works. GPU assignment of Quadro<br>cards is very much like assignment of a NIC. 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. Somehow the idea of rendering into a<br>Window on the host is a common misconception. There is some opportunity<br>to due this, but not with Windows 7 as a guest and at a huge cost to<br>performance. 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>> Steps done so far:<br>> 1. Used virt-manager to create a storage device on a SSD (50GB size)<br>> 2. Installed Windows 7 in VM<br>> 3. Updated Windows 7<br>> 4. Enable virtualization support and added PCI 0000:03:00.0 as a<br>> physical PCI device to the VM.<br>> 5. Thinking I was not done (due to ignorance) I followed the<br>> presentation I linked above to find device to assign:<br>> <br>> $ sudo lspci -nn | grep NVIDIA<br>> 02:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK110B<br>> [GeForce GTX 780 Ti] [10de:100a] (rev a1)<br>> 02:00.1 Audio device [0403]: NVIDIA Corporation GK110 HDMI Audio<br>> [10de:0e1a] (rev a1)<br>> 03:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107GL<br>> [Quadro K2000] [10de:0ffe] (rev a1)<br>> 03:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio<br>> Controller [10de:0e1b] (rev a1)<br>> <br>> 6. Worked on finding the group:<br>> <br>> $ sudo readlink /sys/bus/pci/devices/0000\:03\:00.0/iommu_group<br>> ../../../../kernel/iommu_groups/17<br>> <br>> 7. Now that I have the group I worked to find the devices in the group:<br>> <br>> $ sudo ls /sys/bus/pci/devices/0000\:03\:00.0/iommu_group/devices<br>> 0000:03:00.0 0000:03:00.1<br>> <br>> *** Ok. So two devices need to dealt with here.<br>> <br>> 8. I unbinded each from the device driver<br>> <br>> $ echo 0000:03:00.0 | sudo tee \<br>> /sys/bus/pci/devices/0000:03:00.0/driver/unbind<br>> <br>> $ echo 0000:03:00.1 | sudo tee \<br>> /sys/bus/pci/devices/0000:03:00.1/driver/unbind<br>> <br>> 9. Found the vendor and device ID for each:<br>> <br>> $ sudo lspci -n -s 03:00.0<br>> 03:00.0 0300: 10de:0ffe (rev a1)<br>> $ sudo lspci -n -s 03:00.1<br>> 03:00.1 0403: 10de:0e1b (rev a1)<br>> <br>> 10. Now I bind them to vfio-pci<br>> $ echo 10de 0ffe | sudo tee \<br>> /sys/bus/pci/drivers/vfio-pci/new_id<br>> $ echo 10de 01eb | sudo tee \<br>> /sys/bus/pci/drivers/vfio-pci/new_id<br>> <br>> ** Not sure about this. I am not sure I have bounded them correctly.<br>> <br>> 11. Now checking them I see:<br>> $ ls /dev/vfio<br>> 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. 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. 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. 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. 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. 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. In this mode you can<br>even get 3D graphics in the virt-manager window, but *at greatly reduced<br>performance*. Hope that helps,<br><br>Alex<br><br></body>