Bug 1012824

Summary: the virtual interface can't be hotpluged with command "attach-interface" while the guest contains VF
Product: Red Hat Enterprise Linux 7 Reporter: Xuesong Zhang <xuzhang>
Component: libvirtAssignee: Laine Stump <laine>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, bili, dyuan, honzhang, jiahu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.1.1-9.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1012834 (view as bug list) Environment:
Last Closed: 2014-06-13 10:08:29 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:
Embargoed:
Bug Depends On:    
Bug Blocks: 1012834    

Description Xuesong Zhang 2013-09-27 08:33:11 UTC
Description
After hot-plug/cold-plug one hostdev network interface, can't attach the interface from default network. This issue is about command "attach-interface".

Version:
libvirt-1.1.1-5.el7.x86_64
qemu-kvm-1.5.3-3.el7.x86_64
kernel-3.10.0-23.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare 2 types network on the SR-IOV host: one is default network, the other one is the hostdev network.
# virsh net-dumpxml hostnet
<network connections='2'>
  <name>hostnet</name>
  <uuid>c1fb4ead-21b8-4d69-8ad9-669c55b3dfc7</uuid>
  <forward mode='hostdev' managed='yes'>
    <address type='pci' domain='0x0000' bus='0x03' slot='0x10' function='0x1'/>
    <address type='pci' domain='0x0000' bus='0x03' slot='0x10' function='0x0'/>
  </forward>
</network>

# virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>74b8fbe6-87d3-4e75-90e9-0a92623e1040</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:6d:3f:27'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>

2. prepare one running guest

3. prepare one guest, cold-plug the vf to the guest like following:
# virsh dumpxml a
......
<interface type='network'>
      <mac address='52:54:00:e6:1f:fe'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
......

4. start the guest

5. hot-plug the interface of default network to the guest:
# virsh attach-interface a network default
error: Failed to attach interface
error: internal error: Unable to determine device index for network device

6. hot-plug the interface of hostdev network to the guest:
# virsh attach-interface a network hostnet
Interface attached successfully

7. destroy the guest, then edit the guest and delete the VF, start the guest again.

8. hot-plug the interface of default network to the guest:
# virsh attach-interface a network default
Interface attached successfully

9. hot-plug the interface of hostdev network to the guest:
# virsh attach-interface a network hostnet
Interface attached successfully

10. hot-plug the interface of default network to the guest:
# virsh attach-interface a network default
error: Failed to attach interface
error: internal error: Unable to determine device index for network device

Actual results:
In step5 and step10, after the guest cold-plug/hot-plug one VF, the interface of default network can't be hot-plug to the guest.

Expected results:
In step5 and step10, the interface of default network should be hot-plug successfully to the guest whether there is other type network interface or not.

Additional info:

Comment 2 Laine Stump 2013-10-03 11:30:25 UTC
Fix posted upstream:

https://www.redhat.com/archives/libvir-list/2013-October/msg00152.html

Comment 3 Laine Stump 2013-10-03 15:11:59 UTC
Pushed upstream:

commit 9881bfed2541faa428372b4513518b4b9ae1ab15
Author: Laine Stump <laine>
Date:   Thu Oct 3 13:02:35 2013 +0300

    qemu: check actual netdev type rather than config netdev type during init

Comment 6 Hu Jianwei 2013-10-17 03:07:34 UTC
I can reproduce it with libvirt-1.1.1-8.el7.x86_64, can not reproduce it with libvirt-1.1.1-9.el7.x86_64.

version:
libvirt-1.1.1-9.el7.x86_64
qemu-kvm-rhev-1.5.3-9.el7.x86_64
kernel-3.10.0-33.el7.x86_64

Verifying steps:
1. Define below two virtual networks.
[root@sriov2 ~]# virsh net-dumpxml hostnet
<network>
  <name>hostnet</name>
  <uuid>c1fb4ead-21b8-4d69-8ad9-669c55b3dfc7</uuid>
  <forward mode='hostdev' managed='yes'>
    <address type='pci' domain='0x0000' bus='0x11' slot='0x10' function='0x1'/>
    <address type='pci' domain='0x0000' bus='0x11' slot='0x10' function='0x0'/>
  </forward>
</network>

[root@sriov2 ~]# virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>10f211a3-5f62-4f17-8a74-feb385446629</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:b9:c9:28'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>

2. Prepare one running guest, cold-plug the vf to the guest like following:
[root@sriov2 ~]# virsh start r7
Domain r7 started

[root@sriov2 ~]# virsh dumpxml r7 | grep interface -A10
    <interface type='network'>
      <mac address='52:54:00:f1:17:cc'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
...

3. hot-plug the interface of default network to the guest
[root@sriov2 ~]# virsh attach-interface r7 network default
Interface attached successfully

[root@sriov2 ~]# virsh dumpxml r7 | grep interface -A10
    <interface type='network'>
      <mac address='52:54:00:f1:17:cc'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:2a:70:fa'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </interface>
...

4. hot-plug the interface of hostdev network to the guest
[root@sriov2 ~]# virsh attach-interface r7 network hostnet
Interface attached successfully

[root@sriov2 ~]# virsh dumpxml r7 | grep interface -A10
    <interface type='network'>
      <mac address='52:54:00:f1:17:cc'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:2a:70:fa'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:a8:f1:ec'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>
...

5. hot-plug the interface of default network to the guest again
[root@sriov2 ~]# virsh attach-interface r7 network default
Interface attached successfully

[root@sriov2 ~]# virsh dumpxml r7 | grep interface -A10
    <interface type='network'>
      <mac address='52:54:00:f1:17:cc'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:2a:70:fa'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:a8:f1:ec'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:ab:f5:d9'/>
      <source network='default'/>
      <target dev='vnet1'/>
      <model type='rtl8139'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>
...

6. hot-plug the interface of hostdev network to the guest again, due to there are only two VFs in the pool, so we just cold-plug/hot-plug twice.
[root@sriov2 ~]# virsh attach-interface r7 network hostnet
error: Failed to attach interface
error: internal error: network 'hostnet' requires exclusive access to interfaces, but none are available

7. hot-plug the interface of default network to the guest, after this step, we will get three interfaces that source network is default.
[root@sriov2 ~]# virsh attach-interface r7 network default
Interface attached successfully

[root@sriov2 ~]# virsh dumpxml r7 | grep interface -A10
    <interface type='network'>
      <mac address='52:54:00:f1:17:cc'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:2a:70:fa'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:a8:f1:ec'/>
      <source network='hostnet'/>
      <model type='rtl8139'/>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:ab:f5:d9'/>
      <source network='default'/>
      <target dev='vnet1'/>
      <model type='rtl8139'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:55:49:48'/>
      <source network='default'/>
      <target dev='vnet2'/>
      <model type='rtl8139'/>
      <alias name='net2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </interface>
...

We can get expected results, so changed to verified.

Comment 7 Ludek Smid 2014-06-13 10:08:29 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.