this is VM, There is no bus-info in the uevent file
~]# ethtool -i eth0 | grep bus-info
bus-info: 0000:00:03.0
~]# lshw -C net -businfo
Bus info Device Class Description
=======================================================
pci@0000:00:03.0 network Virtio network device
virtio@0 eth0 network Ethernet interface
~]# cat /sys/class/net/eth0/device/uevent
DRIVER=virtio_net
MODALIAS=virtio:d00000001v00001AF4
this is Physical machine
~]# lshw -C net -businfo | grep I350
pci@0000:61:00.0 eno1 network I350 Gigabit Network Connection
pci@0000:61:00.1 eno2 network I350 Gigabit Network Connection
~]# lspci | grep I350
61:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
61:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
~]# ethtool -i eno1 | grep bus-info
bus-info: 0000:61:00.0
~]# cat /sys/class/net/eno1/device/uevent | grep PCI_SLOT_NAME
PCI_SLOT_NAME=0000:61:00.0
Is there a generic way to get bus-info without using ethtool, lshw, lspci, etc. CLI tools?
Can also try using Go or Python to get bus-info
I use various CLIs to get bus-info, but I want to get bus-info information in a more general way that does not depend on the environment. It would be better if I could get it in Go language.
I read the following questions, but I don’t see a good solution.
- https://askubuntu.com/questions/654820/how-to-find-pci-address-of-an-ethernet-interface
- how to use ethtool_drvinfo to collect driver information for a network interface?