[libvirt] Device attach / detach problem for passthrough/SR-IOV in libvirt

Hi all I just encountered a problem in libvirt while was trying to attach and detach a sr-iov vf to my VM The version of my libvirt is 1.1.1-0ubuntu8.5 I tried to attach the device using following xml <interface type='hostdev' managed='yes'> <mac address='5c:01:fd:12:34:58'/> <source> <address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x1'/> </source> </interface> When i attached device it worked properly and i managed to ping another host. virsh # attach-device t5 1.xml Device attached successfully But when i detached it still i had network traffic in my VM but libvirt (virsh) said that virsh # detach-device t5 1.xml Device detached successfully The next time i tried to attach it libvirt said that virsh # attach-device t5 1.xml error: Failed to attach device from 1.xml error: Requested operation is not valid: PCI device 0000:04:01.1 is in use by domain t5 and when i continue this action after the 'domain' i receive some strange characters which might come from the memory space (memory content) like some addresses, links or some characters I tried it with different VMs and different guest OSs that the same happend. The same action was done with another host running libvirt version Installed: 1.0.2-0ubuntu11.13.04.5~cloud1 Candidate: 1.0.2-0ubuntu11.13.04.5~cloud1 and it worked pretty OK. No problem. Do you have any idea what is wrong? More information: Kernel : 3.8.0-37-generic /etc/libvirt/qemu.conf : security_driver = "none" root@compute01:~# ethtool -i eth5 driver: bnx2x version: 1.78.58 firmware-version: bc 7.4.22 phy 1.34 bus-info: 0000:04:00.1 supports-statistics: yes supports-test: yes supports-eeprom-access: yes supports-register-dump: yes

On 27.03.2014 13:53, Mohsen Ghaemi wrote:
Hi all
I just encountered a problem in libvirt while was trying to attach and detach a sr-iov vf to my VM
The version of my libvirt is 1.1.1-0ubuntu8.5
I tried to attach the device using following xml
<interface type='hostdev' managed='yes'>
<mac address='5c:01:fd:12:34:58'/>
<source>
<address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x1'/>
</source>
</interface>
When i attached device it worked properly and i managed to ping another host.
virsh # attach-device t5 1.xml
Device attached successfully
But when i detached it still i had network traffic in my VM but libvirt (virsh) said that
virsh # detach-device t5 1.xml
Device detached successfully
The next time i tried to attach it libvirt said that
virsh # attach-device t5 1.xml
error: Failed to attach device from 1.xml
error: Requested operation is not valid: PCI device 0000:04:01.1 is in use by domain t5
and when i continue this action after the ‘domain’ i receive some strange characters which might come from the memory space (memory content) like some addresses, links or some characters
I tried it with different VMs and different guest OSs that the same happend.
The same action was done with another host running libvirt version
Installed: 1.0.2-0ubuntu11.13.04.5~cloud1
Candidate: 1.0.2-0ubuntu11.13.04.5~cloud1
This is probably a bug in libvirt. There's been a rework of hostdev plugging and unplugging recently. Can you try the 1.2.3-rc1 and see if the problem is gone? Michal

On Fri, Mar 28, 2014 at 10:34:59 +0100, Michal Privoznik wrote:
On 27.03.2014 13:53, Mohsen Ghaemi wrote:
Hi all
I just encountered a problem in libvirt while was trying to attach and detach a sr-iov vf to my VM
The version of my libvirt is 1.1.1-0ubuntu8.5
I tried to attach the device using following xml
<interface type='hostdev' managed='yes'>
<mac address='5c:01:fd:12:34:58'/>
<source>
<address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x1'/>
</source>
</interface>
When i attached device it worked properly and i managed to ping another host.
virsh # attach-device t5 1.xml
Device attached successfully
But when i detached it still i had network traffic in my VM but libvirt (virsh) said that
virsh # detach-device t5 1.xml
Device detached successfully
Could you run "virsh dumpxml t5" at this point so that we can see if the interface was really removed? The message from detach-device is not always correct (and I'm working on fixing it) since some devices need guest cooperation to be detached and thus this "Device detached successfully" may just mean that we successfully asked the guest to remove the device but it was not in fact removed yet. Jirka

Hi thanks for your reply Since I am working on my master thesis and seriously I am running out of time I decided to downgrade my libvirt from 1.1.1 to 1.0.2 to be able to continue working on my thesis. Now it works ! But for your information , I already checked the XML file and the interface was really removed. I checked my host interfaces using ifconfig -a and I found however I released the device but it is not there and it is not possible to assign it to other VM so I though it means there is some missed procedure or some thing like this to unbind pci device ! as i mentioned if I restarted the libvirt service I was able to attach it again but still it was not shown in ifconfig -a list. The other point that i noticed was the number of "irq"s in my logs for MSI/MSI-X while attaching device. I am not a programmer and I have no clue about interrupts but the point was that in 1.1.1 i cloud see only 2 or 3 "irq" in my logs but now I see 7 or 8 . regards Mohsen On Fri, Mar 28, 2014 at 10:34 AM, Michal Privoznik <mprivozn@redhat.com>wrote:
On 27.03.2014 13:53, Mohsen Ghaemi wrote:
Hi all
I just encountered a problem in libvirt while was trying to attach and detach a sr-iov vf to my VM
The version of my libvirt is 1.1.1-0ubuntu8.5
I tried to attach the device using following xml
<interface type='hostdev' managed='yes'>
<mac address='5c:01:fd:12:34:58'/>
<source>
<address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x1'/>
</source>
</interface>
When i attached device it worked properly and i managed to ping another host.
virsh # attach-device t5 1.xml
Device attached successfully
But when i detached it still i had network traffic in my VM but libvirt (virsh) said that
virsh # detach-device t5 1.xml
Device detached successfully
The next time i tried to attach it libvirt said that
virsh # attach-device t5 1.xml
error: Failed to attach device from 1.xml
error: Requested operation is not valid: PCI device 0000:04:01.1 is in use by domain t5
and when i continue this action after the 'domain' i receive some strange characters which might come from the memory space (memory content) like some addresses, links or some characters
I tried it with different VMs and different guest OSs that the same happend.
The same action was done with another host running libvirt version
Installed: 1.0.2-0ubuntu11.13.04.5~cloud1
Candidate: 1.0.2-0ubuntu11.13.04.5~cloud1
This is probably a bug in libvirt. There's been a rework of hostdev plugging and unplugging recently. Can you try the 1.2.3-rc1 and see if the problem is gone?
Michal
participants (3)
-
Jiri Denemark
-
Michal Privoznik
-
Mohsen Ghaemi