Bug 1832850

Summary: Hot-plug interface into the pcie-downstream-port controller will disappear after a while
Product: Red Hat Enterprise Linux 8 Reporter: yalzhang <yalzhang>
Component: qemu-kvmAssignee: Amnon Ilan <ailan>
qemu-kvm sub component: PCI QA Contact: jingzhao <jinzhao>
Status: CLOSED WONTFIX Docs Contact:
Severity: unspecified    
Priority: unspecified CC: jinzhao, jsuvorov, jusual, juzhang, laine, meili, virt-maint
Version: 8.2   
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-05 08:59:57 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:

Description yalzhang@redhat.com 2020-05-07 11:59:58 UTC
Description of problem:
Hot-plug interface into the pcie-downstream-port controller will disappear after a while

Version-Release number of selected component (if applicable):
# rpm -q libvirt qemu-kvm
libvirt-6.0.0-18.module+el8.2.1+6456+a6d62e4e.x86_64
qemu-kvm-4.2.0-20.module+el8.2.1+6467+49dc3278.x86_64

It can also be reproduced on rhel8.2.0 av:
# rpm -q libvirt-libs qemu-kvm
libvirt-libs-6.0.0-17.module+el8.2.0+6257+0d066c28.x86_64
qemu-kvm-4.2.0-19.module+el8.2.0+6296+6b821950.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare an vm with pcie-switch-upstream-port and pcie-switch-downstream-port controller:
# virsh dumpxml vm2
...
<controller type='pci' index='0' model='pcie-root'/>
...
<controller type='pci' index='7' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='7' port='0x16'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x6'/>
    </controller>
 <controller type='pci' index='8' model='pcie-switch-upstream-port'>
      <model name='x3130-upstream'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </controller>
    <controller type='pci' index='9' model='pcie-switch-downstream-port'>
      <model name='xio3130-downstream'/>
      <target chassis='9' port='0x0'/>
      <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
    </controller>
...
2. Start the vm, hotplug interface to the downstream port:
# virsh start vm2

# cat net.xml
<interface type='network'>
<mac address='52:54:11:22:33:44'/>
      <source network='default'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
    </interface>

# virsh domiflist vm2
 Interface   Type      Source    Model    MAC
-------------------------------------------------------------
 vnet0       network   default   virtio   52:54:00:86:f7:83

# virsh attach-device vm2 net.xml ; virsh domiflist vm2 ; sleep 5; echo "after sleep 5"; virsh domiflist vm2
Device attached successfully

 Interface   Type      Source    Model    MAC
-------------------------------------------------------------
 vnet0       network   default   virtio   52:54:00:86:f7:83
 vnet1       network   default   virtio   52:54:11:22:33:44

after sleep 5
 Interface   Type      Source    Model    MAC
-------------------------------------------------------------
 vnet0       network   default   virtio   52:54:00:86:f7:83

3. check on guest, there are error prompted:
[root@localhost ~]# [  740.394901] pcieport 0000:08:00.0: Slot(0-7): Attention button pressed
[  740.399225] pcieport 0000:08:00.0: Slot(0-7) Powering on due to button press
[  740.403163] pcieport 0000:08:00.0: Slot(0-7): Card present
[  740.405830] pcieport 0000:08:00.0: Slot(0-7): Link Up
[  741.536309] pcieport 0000:08:00.0: link training error: status 0x2000
[  741.539890] pcieport 0000:08:00.0: Failed to check link status

Actual results:
In step2, the interface disappeared after hotplug successfully

Expected results:
The interface should not disappear on the guest. If the hotplug is not supported, it should report error during hotplug

Additional info:

Comment 2 John Ferlan 2020-05-15 14:12:06 UTC
Assigned to Amnon for initial triage per bz process and age of bug created or assigned to virt-maint without triage

Comment 4 Laine Stump 2020-06-16 14:05:06 UTC
I'm pretty sure this behavior was reported in a previous BZ - basically the pcie-downstream-port is for some reason unplugged by the Linux kernel some time after the guest OS boots. I don't know if this is a problem with the emulated controller in qemu, or with the guest kernel (seems more likely the former).