Bug 1036613

Summary: PCI NIC device attach to VM doesn't work
Product: [Fedora] Fedora Reporter: Juan Rodriguez <jrodrigu>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 20CC: aglotov, berrange, clalancette, itamar, jforbes, jyang, laine, libvirt-maint, veillard, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-02 12:31:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Juan Rodriguez 2013-12-02 10:56:14 UTC
Description of problem:
After create a Fedora 20 VM and attach a PCI device which is a NIC in virt-manager and start VM I receive this errors:

Error starting domain: internal error: process exited while connecting to monitor: qemu-system-x86_64: -device pci-assign,configfd=26,host=3f:00.0,id=hostdev0,bus=pci.0,addr=0x9: No IOMMU found.  Unable to assign device "hostdev0"
qemu-system-x86_64: -device pci-assign,configfd=26,host=3f:00.0,id=hostdev0,bus=pci.0,addr=0x9: Device initialization failed.
qemu-system-x86_64: -device pci-assign,configfd=26,host=3f:00.0,id=hostdev0,bus=pci.0,addr=0x9: Device 'kvm-pci-assign' could not be initialized


Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 91, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 127, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/domain.py", line 1260, in startup
    self._backend.create()
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 708, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: internal error: process exited while connecting to monitor: qemu-system-x86_64: -device pci-assign,configfd=26,host=3f:00.0,id=hostdev0,bus=pci.0,addr=0x9: No IOMMU found.  Unable to assign device "hostdev0"
qemu-system-x86_64: -device pci-assign,configfd=26,host=3f:00.0,id=hostdev0,bus=pci.0,addr=0x9: Device initialization failed.
qemu-system-x86_64: -device pci-assign,configfd=26,host=3f:00.0,id=hostdev0,bus=pci.0,addr=0x9: Device 'kvm-pci-assign' could not be initialized


Version-Release number of selected component (if applicable):

rpm -q virt-manager
virt-manager-0.10.0-5.git1ffcc0cc.fc20.noarch

rpm -qa libvirt
libvirt-1.1.3.1-2.fc20.x86_64

uname -a
Linux dhcp-1-107.brq.redhat.com 3.11.9-300.fc20.x86_64 #1 SMP Wed Nov 20 22:23:25 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

dmesg | grep IOMMU
[    0.000000] Intel-IOMMU: enabled

How reproducible:
Create a Fedora 20 VM with virt-manager and add hardware, PCI Host Device, choosing the NIC that you want to add, and click on Finish.

Steps to Reproduce:
1.
2.
3.

Actual results:
Error, It doesn't work.

Expected results:
I should be work without problems.

Additional info:

Comment 1 Laine Stump 2013-12-02 12:31:12 UTC
> Error starting domain: internal error: process exited while connecting
> to monitor: qemu-system-x86_64: -device 
> pci-assign,configfd=26,host=3f:00.0,id=hostdev0,bus=pci.0,addr=0x9:
> No IOMMU found.

Note the error message.

It takes more to assign a device to a guest than just asking for it in virt-manager. First your hardware has to be capable of it. Then you have to add the proper options to your kernel commandline to enable it. And if you want to use VFIO device assignment (which is much preferred if you're running F20 or better) you will need to make sure the vfio-pci kernel module is loaded.

This (slightly outdated, because it doesn't reference VFIO) guide describes some of that:

https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Host_Configuration_and_Guest_Installation_Guide/chap-Virtualization_Host_Configuration_and_Guest_Installation_Guide-PCI_Device_Config.html

Beyond that, if the device you're assigning is a virtual function (VF) of an SRIOV-capable network card, you should read this:

http://wiki.libvirt.org/page/Networking#PCI_Passthrough_of_host_network_devices

I'm preemptively closing this bug. If you still have problems, please ask in IRC on #virt (irc.oftc.net) or send email with details of your hardware and kernel commandline to libvirt-users before re-opening. (In the end, it is possible that assigning your selected network device to a guest simply isn't possible.)