Browse Source

Fix SR-IOV availability check

It's possible that SR-IOV is listed in capatibilities but
Total VFs is equal to zero. In such case nailgun-agent should
report that SR-IOV is not available.

Change-Id: I564b5135831f63e591296b1c5dfbe933687bc7d8
Closes-bug: #1564630
Aleksandr Didenko 3 years ago
parent
commit
f20415917c
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      agent

+ 5
- 2
agent View File

@@ -292,8 +292,11 @@ class NodeAgent
292 292
     sriov = DEFAULT_SRIOV.dup
293 293
     lspci = _get_lspci_info(int_bus_info)
294 294
     if lspci.match(/.*Capabilities:.*SR-IOV.*/)
295
-      sriov["available"] = true
296
-      sriov["sriov_totalvfs"] = lspci.scan(/\s+Total\s+VFs:\s+(\d+)/).last.first.to_i - 1
295
+      sriov["sriov_totalvfs"] = lspci.scan(/\s+Total\s+VFs:\s+(\d+)/).last.first.to_i
296
+      unless sriov["sriov_totalvfs"] == 0
297
+        sriov["available"] = true
298
+        sriov["sriov_totalvfs"] -= 1
299
+      end
297 300
       vf_vendor = File.read("/sys/class/net/#{int}/device/vendor").chomp.gsub(/^0x/, '')
298 301
       vf_device = lspci.scan(/VF\s+.*\s+Device\s+ID:\s+([A-Fa-f0-9]+)/).last.first
299 302
       sriov["pci_id"] = "#{vf_vendor}:#{vf_device}"

Loading…
Cancel
Save