Browse Source

Read device PCIID instead of subsystem one

For some devices like Virtio network device [1af4:1000], there is
invalid PCIID in /sys/class/net.

Change-Id: I3bc514c2d57e3a7669c418e49830491041cb8f52
Closes-Bug: #1655733
(cherry picked from commit 0a306b1dc7)
changes/68/419568/1
Vladimir Eremin 2 years ago
parent
commit
5e119e08c3
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      agent

+ 4
- 4
agent View File

@@ -511,9 +511,9 @@ class NodeAgent
511 511
     DEFAULT_SRIOV
512 512
   end
513 513
 
514
-  def nic_pci_id(int)
515
-    vendor = File.read("/sys/class/net/#{int}/device/vendor").chomp.gsub(/^0x/, '')
516
-    device = File.read("/sys/class/net/#{int}/device/device").chomp.gsub(/^0x/, '')
514
+  def nic_pci_id(bus_info)
515
+    vendor = File.read("/sys/bus/pci/devices/#{bus_info}/vendor").chomp.gsub(/^0x/, '')
516
+    device = File.read("/sys/bus/pci/devices/#{bus_info}/device").chomp.gsub(/^0x/, '')
517 517
     "#{vendor}:#{device}"
518 518
   rescue
519 519
     ""
@@ -701,7 +701,7 @@ class NodeAgent
701 701
         # Getting SR-IOV info
702 702
         int_meta[:interface_properties][:sriov] = sriov_info(int, int_meta[:bus_info])
703 703
         # Get PCI-ID
704
-        int_meta[:interface_properties][:pci_id] = nic_pci_id(int)
704
+        int_meta[:interface_properties][:pci_id] = nic_pci_id(int_meta[:bus_info])
705 705
         # Get numa node
706 706
         int_meta[:interface_properties][:numa_node] = nic_numa_node(int_meta[:bus_info])
707 707
         # Get maximum queues

Loading…
Cancel
Save