aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-07-03 10:35:21 -0400
committerJake Hunsaker <jhunsake@redhat.com>2020-07-03 10:45:27 -0400
commit1c87810faf65fa2c6165d917dd3cc51b3c90a969 (patch)
tree410a8ab75349f00b2d94cd5184b1388d0b947242
parent047bf4048ccbe6c54786df04729208ddff513f40 (diff)
downloadsos-1c87810faf65fa2c6165d917dd3cc51b3c90a969.tar.gz
[pci] Update gating for lspci commands
It was reported that certain arches may create subdir structures under /proc/bus/pci differently than others - most notably that the first device subdir could be '0000:00' instead of just '00'. Rather than chase these different layouts, update the gating check for running `lspci` commands to being that /proc/bus/pci exists and it has more than just the `devices` file present, as this file may be present but empty when nothing else exists under `/proc/bus/pci`. Resolves: #2138 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/report/plugins/pci.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/sos/report/plugins/pci.py b/sos/report/plugins/pci.py
index 91d2709e..cd3da9bc 100644
--- a/sos/report/plugins/pci.py
+++ b/sos/report/plugins/pci.py
@@ -17,6 +17,16 @@ class Pci(Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin):
plugin_name = "pci"
profiles = ('hardware', 'system')
+ def check_for_bus_devices(self):
+ if not os.path.isdir('/proc/bus/pci'):
+ return False
+ # ensure that more than just the 'devices' file, which can be empty,
+ # exists in the pci directory. This implies actual devices are present
+ content = os.listdir('/proc/bus/pci')
+ if 'devices' in content:
+ content.remove('devices')
+ return len(content) > 0
+
def setup(self):
self.add_copy_spec([
"/proc/ioports",
@@ -24,7 +34,7 @@ class Pci(Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin):
"/proc/bus/pci"
])
- if os.path.isdir("/proc/bus/pci/00"):
+ if self.check_for_bus_devices():
self.add_cmd_output("lspci -nnvv", root_symlink="lspci")
self.add_cmd_output("lspci -tv")