Skip to content

Commit 80769c7

Browse files
mcgovCopilot
andauthored
Lspci: only refresh the pciids database once per node
get_devices ran update-pciids on every forced refresh, which adds a network download and a noticeable delay to hot plug tests that rescan the pci bus repeatedly. Track whether the database was already updated for this tool instance and skip the refresh afterwards. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5d5f58ad-b9df-4420-ad37-22caee78e925
1 parent a32969a commit 80769c7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lisa/tools/lspci.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def can_install(self) -> bool:
196196
def _initialize(self, *args: Any, **kwargs: Any) -> None:
197197
self._command = "lspci"
198198
self._pci_devices: List[PciDevice] = []
199+
self._pciids_initialized: bool = False
199200

200201
def _install(self) -> bool:
201202
if isinstance(self.node.os, Posix):
@@ -293,10 +294,12 @@ def get_devices_by_type(
293294
@retry(KeyError, tries=30, delay=2) # type: ignore
294295
def get_devices(self, force_run: bool = False) -> List[PciDevice]:
295296
if (not self._pci_devices) or force_run:
297+
if not self._pciids_initialized:
298+
# Ensure pci device ids and name mappings are updated.
299+
self.node.execute("update-pciids", sudo=True, shell=True)
300+
self._pciids_initialized = True
296301
self._pci_devices = []
297302
self._pci_ids = {}
298-
# Ensure pci device ids and name mappings are updated.
299-
self.node.execute("update-pciids", sudo=True, shell=True)
300303

301304
# Fetching the id information using 'lspci -nnm' is not reliable
302305
# due to inconsistencies in device id patterns.

0 commit comments

Comments
 (0)