Bug 1558655

Summary: [SR-IOV] - Can't start VM with SR-IOV vNIC [rhel-7.5.z]
Product: Red Hat Enterprise Linux 7 Reporter: Oneata Mircea Teodor <toneata>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: yafu <yafu>
Severity: high Docs Contact:
Priority: high    
Version: 7.0CC: bugs, danken, dyuan, jdenemar, jherrman, jiyan, jsuchane, mburman, michal.skrivanek, mkalfon, mprivozn, ratamir, rbalakri, salmy, spower, xuzhang, yafu, yalzhang
Target Milestone: rcKeywords: Upstream, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.9.0-14.el7_5.2 Doc Type: Bug Fix
Doc Text:
Prior to this update, if the "interface type='hostdev'" configuration was used for a guest virtual machine, booting the guest in some cases failed due to a validation error. With this update, the libvirt service has been fixed to ignore hostdev duplicates in the XML configuration. As a result, the guest boots correctly in the described scenario.
Story Points: ---
Clone Of: 1556828 Environment:
Last Closed: 2018-04-10 19:13:42 UTC Type: ---
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: 1556828    
Bug Blocks:    

Description Oneata Mircea Teodor 2018-03-20 17:25:53 UTC
This bug has been copied from bug #1556828 and has been proposed to be backported to 7.5 z-stream (EUS).

Comment 5 yafu 2018-03-21 10:15:34 UTC
Test with libvirt-3.9.0-14.el7_5.2.x86_64.

Test steps:
(1)Scenario 1: hotplug->unhotplug->hotplug hostdev interface with alias name:
1.Start a guest:
#virsh start iommu1
Domain iommu1 started

2.Prepare a hostdev interface with alias name:
#cat interface.xml
<interface type='hostdev' managed='yes'>
  <mac address='66:18:0b:c2:85:b8'/>
  <source>
    <address type='pci' domain='0x0000' bus='0x04' slot='0x10' function='0x3'/>
  </source>
  <alias name='ua-04c2decd-4e33-4023-84de-a2205c777af7'/>
  <model type='virtio'/>
</interface>

3.Hotplug the hostdev interface deto the guest:
#virsh attach-device iommu1 interface.xml
Device attached successfully

4.Check the hostdev interface in the live guest xml:
#virsh dumpxml iommu1 | grep -A10 interface
<interface type='hostdev' managed='yes'>
      <mac address='66:18:0b:c2:85:b8'/>
      <driver name='vfio'/>
    ...
      <alias name='ua-04c2decd-4e33-4023-84de-a2205c777af7'/>
    ...
</interface>

5.Hotunplug the hostdev interface from the guest:
#virsh detach-device iommu1 interface.xml
Device detached successfully

6.Check the hostdev interface in the live guest xml:
#virsh dumpxml iommu1  | grep hostdev
no output

7.Repeat step3-4, the hostdev interface can attach successfully to the guest.

(2)Scenario 2: coldplug->coldunplug hostdev interface with alias name:
1.Coldplug hostdev interface to guest:
#virsh attach-device iommu1 interface.xml --config
Device detached successfully

2.Start the guest:
#virsh start iommu1
Domain iommu1 started

3.Check the hostdev interface in the live xml:
#virsh dumpxml iommu1 | grep -A10 interface
<interface type='hostdev' managed='yes'>
      <mac address='66:18:0b:c2:85:b8'/>
      <driver name='vfio'/>
    ...
      <alias name='ua-04c2decd-4e33-4023-84de-a2205c777af7'/>
    ...
</interface>

4.Coldunplug the hostdev interface from the guest:
#virsh detach-device iommu1 interface.xml --config
Device detached successfully

5.Check the hostdev interface in the inactive domain xml:
#virsh dumpxml iommu1 --inactive | grep -i hostdev
no output

(3)Scenario 3: Hotplug hostdev interface with the same alias name:
1.Attach the hostdev interface device with alias name to the guest:
#virsh attach-device iommu1 interface.xml
Device attached successfully

2.Repeat step 1:
#virsh attach-device iommu1 interface.xml
error: Failed to attach device from /nic-xml/interface.xml
error: XML error: non unique alias detected: ua-04c2decd-4e33-4023-84de-a2205c777af

Comment 6 Michal Privoznik 2018-03-21 10:35:04 UTC
Restoring doc text I added earlier.

Comment 7 yafu 2018-03-22 04:53:22 UTC
Hi,Michael,

Could you help to test this bug from RHV with libvirt-3.9.0-14.el7_5.2.x86_64 please?

Thanks a lot.

Comment 8 Michael Burman 2018-03-22 09:09:19 UTC
(In reply to yafu from comment #7)
> Hi,Michael,
> 
> Could you help to test this bug from RHV with
> libvirt-3.9.0-14.el7_5.2.x86_64 please?
> 
> Thanks a lot.

Hi Yafu, sure np
can you please send me the link to this version build(RPM) and i will test it)

Comment 11 yafu 2018-03-23 05:03:04 UTC
Hi,Michal,

I found when hotunplug device from the guest, libvirt did not check the alias name. 
Could you help to check that please? Thanks.

Test steps:
1.Prepare hostdev interface xml:
#cat interface.xml-1
<interface type='hostdev' managed='yes'>
  <mac address='66:18:0b:c2:85:b8'/>
  <source>
    <address type='pci' domain='0x0000' bus='0x04' slot='0x10' function='0x3'/>
  </source>
  ***<alias name='ua-04c2decd-4e33-4023-84de-a2205c777af7'/>***
  <model type='virtio'/>
</interface>

2.Hotplug the hotdev interface to the guest:
#virsh attach-device iommu1 interface.xml-1
Device attached successfully

3.Check the live xml:
#virsh dumpxml iommu1 | grep -A10 interface
<interface type='hostdev' managed='yes'>
      <mac address='66:18:0b:c2:85:b8'/>
      <driver name='vfio'/>
    ...
      ***<alias name='ua-04c2decd-4e33-4023-84de-a2205c777af7'/>***
    ...
</interface>


4.Prepare another hostdev interface xml with different alias name:
#cat interface.xml-2
<interface type='hostdev' managed='yes'>
  <mac address='66:18:0b:c2:85:b8'/>
  <source>
    <address type='pci' domain='0x0000' bus='0x04' slot='0x10' function='0x3'/>
  </source>
  ***<alias name='ua-04c2decd'/>***
  <model type='virtio'/>
</interface>

5.Hotunplug the hostdev interface from guest:
#virsh detach-device iommu1 interface.xml-2
Device detached successfully

6.Check the live xml and found the hostdev interface detached successfully.

Comment 12 Michal Privoznik 2018-03-23 08:16:20 UTC
(In reply to yafu from comment #11)
> Hi,Michal,
> 
> I found when hotunplug device from the guest, libvirt did not check the
> alias name. 
> Could you help to check that please? Thanks.
> 

This is expected. Libvirt makes no promises on which device attributes it uses to find the matching device in domain definition. That's why users are required to pass whole device XML. Having said that, for <interface/> it currently uses MAC address.

Comment 15 yafu 2018-03-26 04:59:36 UTC
According to comment 5 and comment 13, move the bug to verified.

Comment 18 errata-xmlrpc 2018-04-10 19:13:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:1056