Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
The FDP team is no longer accepting new bugs in Bugzilla. Please report your issues under FDP project in Jira. Thanks.

Bug 2181229

Summary: vhostuser port reconnect failed when use pexpect and time.sleep to start testpmd
Product: Red Hat Enterprise Linux Fast Datapath Reporter: mhou <mhou>
Component: DPDKAssignee: Maxime Coquelin <maxime.coquelin>
DPDK sub component: other QA Contact: mhou <mhou>
Status: CLOSED EOL Docs Contact:
Severity: medium    
Priority: medium CC: ctrautma, fleitner, jhsiao, ktraynor, kzhang
Version: RHEL 9.0   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-10-08 17:49:14 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: 2129066    
Bug Blocks:    

Description mhou 2023-03-23 11:04:51 UTC
Description of problem:
guest still wait for vhostuserport connected. When use pexpect and time.sleep to start a testpmd

Version-Release number of selected component (if applicable):
dpdk version:
dpdk-22.11-1.el9.x86_64
dpdk-tools-22.11-1.el9.x86_64
# pip3 list | grep pexpect
pexpect              4.8.0
python3-3.9.16-1.el9.x86_64
How reproducible: 100%


Steps to Reproduce:
1. create a python script as below:
import sys
import pexpect
testpmd_cmd=sys.argv[1]
cpu1=int(sys.argv[2])
cpu2=int(sys.argv[3])
cpu3=int(sys.argv[4])
port1=int(sys.argv[5])
port2=int(sys.argv[6])
port3=int(sys.argv[7])
port4=int(sys.argv[8])
#exe.logfile_read = sys.stdout
#exe.logfile = sys.stdout
#cmd
cmd="{} -l {},{},{} -n 4 --socket-mem 1024,1024 --vdev net_vhost0,iface=/tmp/vhostuser/vhost0,client=1,queues=1,iommu-support=1 --vdev net_vhost1,iface=/tmp/vhostuser/vhost1,client=1,queues=1,iommu-support=1 -- -i --nb-cores=2 --txq=1 --rxq=1 --forward-mode=io".format(testpmd_cmd,cpu1,cpu2,cpu3)
exe=pexpect.spawn(cmd, encoding='utf-8')
exe.logfile = sys.stdout
exe.expect(['Done',pexpect.EOF, pexpect.TIMEOUT])
#exe.sendline('set portlist 0,2,1,3')
exe.sendline('set portlist {},{},{},{}'.format(port1,port2,port3,port4))
exe.expect('testpmd>')
exe.sendline('start')
exe.expect('testpmd>')
#exe.sendline('show port summary all')
exe.expect('testpmd>')
import time
time.sleep(6000)

2. create a guest xml as below
<domain type='kvm'>
  <name>g1</name>
  <memory unit='KiB' dumpCore="on">8388608</memory>
  <currentMemory unit='KiB'>8388608</currentMemory>
  <memoryBacking>
    <hugepages>
      <page size='1048576' unit='KiB'/>
    </hugepages>
    <locked/>
    <access mode='shared'/>
  </memoryBacking>
  <vcpu placement='static'>3</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='26'/>
    <vcpupin vcpu='1' cpuset='4'/>
    <vcpusched vcpus='1' scheduler='fifo' priority='1'/>
    <vcpupin vcpu='2' cpuset='28'/>
    <vcpusched vcpus='2' scheduler='fifo' priority='1'/>
    <emulatorpin cpuset='6'/>
  </cputune>
  <numatune>
    <memory mode='strict' nodeset='0'/>
    <memnode cellid='0' mode='strict' nodeset='0'/>
  </numatune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='q35'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <pmu state='off'/>
    <vmport state='off'/>
    <ioapic driver='qemu'/>
  </features>
  <cpu mode='host-passthrough' check='none'>
    <feature policy='require' name='tsc-deadline'/>
    <numa>
      <cell id='0' cpus='0-2' memory='8388608' unit='KiB' memAccess='shared'/>
    </numa>
  </cpu>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/g1.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='none'>
      <alias name='usb'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'>
      <alias name='pcie.0'/>
    </controller>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x10'/>
      <alias name='pci.1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </controller>
    <controller type='pci' index='2' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='2' port='0x11'/>
      <alias name='pci.2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </controller>
    <controller type='pci' index='3' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='3' port='0x8'/>
      <alias name='pci.3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='4' port='0x9'/>
      <alias name='pci.4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <controller type='pci' index='5' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='5' port='0xa'/>
      <alias name='pci.5'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>
    <controller type='pci' index='6' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='6' port='0xb'/>
      <alias name='pci.6'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:01:02:03'/>
      <source bridge='virbr0'/>
      <model type='virtio'/>
    </interface>
<interface type='vhostuser'>
  <mac address='00:de:ad:00:00:01'/>
  <source type='unix' path='/tmp/vhostuser/vhost0' mode='server'/>
  <model type='virtio'/>
  <driver name='vhost' rx_queue_size='1024' tx_queue_size='1024' iommu='off' ats='off'>
  <host mrg_rxbuf='off'/>
  </driver>
  <address type='pci' domain='0x0000' bus='0x3' slot='0x00' function='0x0'/>
</interface>
<interface type='vhostuser'>
  <mac address='00:de:ad:00:00:02'/>
  <source type='unix' path='/tmp/vhostuser/vhost1' mode='server'/>
  <model type='virtio'/>
  <driver name='vhost' rx_queue_size='1024' tx_queue_size='1024' iommu='off' ats='off'>
  <host mrg_rxbuf='off'/>
  </driver>
  <address type='pci' domain='0x0000' bus='0x4' slot='0x00' function='0x0'/>
</interface>
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'>
      <alias name='input0'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input1'/>
    </input>
    <graphics type='vnc' port='5900' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    </memballoon>
    <iommu model='intel'>
      <driver intremap='on' caching_mode='on' iotlb='on'/>
    </iommu>
  </devices>
</domain>

3. use script which create in step1 to start dpdk-testpmd
python3 /root/start_testpmd.py dpdk-testpmd 47 23 46 0 2 1 3
# ps -aux | grep testpmd
root        3525  0.0  0.0  11932 10184 pts/1    S+   04:59   0:00 python3 /root/start_testpmd.py dpdk-testpmd 47 23 46 0 2 1 3
root        3526  199  0.1 155498032 79128 pts/3 SLsl+ 04:59 141:36 /usr/bin/dpdk-testpmd -l 47,23,46 -n 4 --socket-mem 1024 1024 --vdev net_vhost0,iface=/tmp/vhostuser/vhost0,client=1,queues=1,iommu-support=1 --vdev net_vhost1,iface=/tmp/vhostuser/vhost1,client=1,queues=1,iommu-support=1 -- -i --nb-cores=2 --txq=1 --rxq=1 --forward-mode=io

4. start guest
virsh create g1.xml

5. reboot guest
virsh reboot g1

6 check guest log as below:
2023-03-22T16:58:19.960304Z qemu-kvm: -chardev socket,id=charnet1,path=/tmp/vhostuser/vhost0,server=on: info: QEMU waiting for connection on: disconnected:unix:/tmp/vhostuser/vhost0,server=on
2023-03-22T18:10:59.592387Z qemu-kvm: -chardev socket,id=charnet2,path=/tmp/vhostuser/vhost1,server=on: info: QEMU waiting for connection on: disconnected:unix:/tmp/vhostuser/vhost1,server=on
char device redirected to /dev/pts/1 (label charserial0)
2023-03-22T18:10:59.663982Z qemu-kvm: -netdev {"type":"vhost-user","chardev":"charnet1","id":"hostnet1"}: Failed to read msg header. Read -1 instead of 12. Original request 1.
2023-03-22T18:10:59.664013Z qemu-kvm: -netdev {"type":"vhost-user","chardev":"charnet1","id":"hostnet1"}: vhost_backend_init failed: Protocol error
2023-03-22T18:10:59.664024Z qemu-kvm: -netdev {"type":"vhost-user","chardev":"charnet1","id":"hostnet1"}: failed to init vhost_net for queue 0
2023-03-22T18:10:59.664059Z qemu-kvm: -netdev {"type":"vhost-user","chardev":"charnet1","id":"hostnet1"}: info: QEMU waiting for connection on: disconnected:unix:/tmp/vhostuser/vhost0,server=on

Actual results:
1. guest reboot failed and still waiting vhostuser port connected.

Expected results:
2. guest reboot as well

Additional info:
if I use exe.interact() to instead of time.sleep, guest reboot as well.
import sys
import pexpect
#exe.logfile_read = sys.stdout
#exe.logfile = sys.stdout
#cmd
cmd="dpdk-testpmd -n 4 --socket-mem 1024,1024 --vdev net_vhost0,iface=/tmp/vhostuser/vhost0,client=1,queues=1,iommu-support=1 --vdev net_vhost1,iface=/tmp/vhostuser/vhost1,client=1,queues=1,iommu-support=1 -- -i --nb-cores=1 --txq=1 --rxq=1 --forward-mode=io"
exe=pexpect.spawn(cmd, encoding='utf-8')
exe.logfile = sys.stdout
exe.expect(['Done',pexpect.EOF, pexpect.TIMEOUT])
#exe.sendline('set portlist 0,2,1,3')
exe.sendline('set portlist 0,1')
exe.expect('testpmd>')
exe.sendline('start')
exe.expect('testpmd>')
#exe.sendline('show port summary all')
exe.expect('testpmd>')
exe.logfile = None
exe.interact()

run same test script can't hit this issue on dpdk-21.11-2.el9_0

Comment 1 ovs-bot 2024-10-08 17:49:14 UTC
This bug did not meet the criteria for automatic migration and is being closed.
If the issue remains, please open a new ticket in https://issues.redhat.com/browse/FDP