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)
tags/9.2
Vladimir Eremin 2 years ago
parent
commit
c14c0b208b
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      agent

+ 4
- 4
agent View File

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

Loading…
Cancel
Save