Skip to content

utils_sriov.get_pf_info() cannot get iface name due to prefix '0000:' #3565

@nluu-ampere

Description

@nluu-ampere

Hi,
I got the issue with this code when run sriov test!

    status, output = utils_misc.cmd_status_output(
        "lspci |awk '/Ethernet/ {print $1}'", shell=True, session=session)
    if status or not output:
        raise exceptions.TestError("Unable to get Ethernet controllers. status: %s,"
                                   "stdout: %s." % (status, output))
    for pci in output.split():
        _, output = utils_misc.cmd_status_output("lspci -v -s %s" % pci,
                                                 shell=True,
                                                 session=session)
        if re.search("SR-IOV", output):
            pf_driver = re.search('driver in use: (.*)', output)[1]
            tmp_info = {'driver': pf_driver, 'pci_id': '0000:%s' % pci}

            iface_name = get_iface_name('0000:%s' % pci, session=session)

This code work when command "lspci |awk '/Ethernet/ {print $1}'" return pcie bus with short format like 02:00.0 Ethernet ... mean domain numbers are omitted since they are all equal to zero!
but, on my system return output with the domain numbers are highlighted.
eg:

lspci  | grep Ethernet
0000:01:00.0 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx]
0000:01:00.1 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx]

I suggest using -D in command lspci and remove prefix 0000:

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions