1

This is on Ubuntu 12.04LTS using KVM. The system has a graphics card which is visible to the hypervisor's kernel shown as follows:

# virsh nodedev-dumpxml pci_0000_21_00_0
<device>
  <name>pci_0000_21_00_0</name>
  <parent>pci_0000_20_02_0</parent>
  <driver>
    <name>nvidia</name>
  </driver>
  <capability type='pci'>
    <domain>0</domain>
    <bus>33</bus>
    <slot>0</slot>
    <function>0</function>
    <product id='0x0a65'>GT218 [GeForce 210]</product>
    <vendor id='0x10de'>NVIDIA Corporation</vendor>
    <capability type='virt_functions'>
    </capability>
  </capability>
</device>

There is also a PCI Function #1 which is the audio portion of the card for which I omitted the dumpxml.

In my domain XML, I have the following:

<hostdev mode='subsystem' type='pci' managed='yes'>
  <source>
    <address domain='0x0000' bus='0x21' slot='0x00' function='0x0'/>
  </source>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
  <source>
    <address domain='0x0000' bus='0x21' slot='0x00' function='0x1'/>
  </source>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/>
</hostdev>

Without these hostdev tags my guest VM boots up just fine (it is also an Ubuntu 12.04LTS kernel). When I try to start the VM with them I get:

# virsh nodedev-detach pci_0000_21_00_0
Device pci_0000_21_00_0 detached

# virsh nodedev-detach pci_0000_21_00_1
Device pci_0000_21_00_1 detached

# virsh start testv
error: Failed to start domain testv
error: Unable to read from monitor: Connection reset by peer

Can anyone say what is going wrong?

UPDATE: Being somewhat new to KVM I didn't realize there was a log file available. It says this:

Failed to assign device "hostdev0" : Device or resource busy
*** The driver 'pci-stub' is occupying your device 0000:21:00.0.
***
*** You can try the following commands to free it:
***
*** $ echo "10de 0a65" > /sys/bus/pci/drivers/pci-stub/new_id
*** $ echo "0000:21:00.0" > /sys/bus/pci/drivers/pci-stub/unbind
*** $ echo "0000:21:00.0" > /sys/bus/pci/drivers/pci-stub/bind
*** $ echo "10de 0a65" > /sys/bus/pci/drivers/pci-stub/remove_id
***
kvm: -device pci-assign,host=21:00.0,id=hostdev0,configfd=30,bus=pci.0,multifunction=on,addr=0x4: Device 'pci-assign' could not be initialized
2014-12-17 19:15:52.368+0000: shutting down

So apparently the nodedev-detatch command leaves a stub driver active? Are the suggested commands to be run in the hypervisor or the VM?

  • 1
    You seem to have installed the NVIDIA proprietary graphics drivers on the host. If you mean to use this card on the guest, and you aren't using any other NVIDIA cards, try uninstalling this driver. – Michael Hampton Dec 17 '14 at 20:26
  • @MichaelHampton Yes I did install the nvidia driver in the hypervisor. My expectation was that it would be effectively disabled if its device was reassigned to a VM by virtlib. However your suggestion makes sense so I will give it a try. – AlanObject Dec 19 '14 at 20:12
  • @MichaelHampton your suggestion worked -- if you want to post it as an answer I'll check it for you. – AlanObject Dec 19 '14 at 22:58
2

You seem to have installed the NVIDIA proprietary graphics drivers on the host. If you mean to use this card on the guest, and you aren't using any other NVIDIA cards, try uninstalling this driver.

2

If i'm not wrong, you are trying to pass through host's present VGA to a VM. frankly this is a bit tricky, there are many requirements, starts from hardware. First, you need

  • A proper CPU that supports Intel VT-d (directed I/O)
  • A Mobo that supports VT-d and iommu.
  • Your linux kernel must be compiled with intel_iommu (Fedora & Ubuntu supports by default)
  • Host started with grub parameter "intel_iommu=on"

Then KVM will be able to use your host's graphic card to expose to VM by QEMU. here is a good guide for this.

  • thanks for the pointers but I am pretty sure that I have all that available. For example I can do PCI pass-through on NICs without any problem and I wouldn't be able to without VT-d/iommu. However video seems to be handled differently for some reason. – AlanObject Dec 19 '14 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.