From c3ad4b3179a97bf22261d95fb4db67de77e1f173 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 27 Apr 2022 16:15:32 +0200 Subject: [statistics] Honor pci device revision for passthrough display --- modules-available/statistics/inc/hardwareparserlegacy.inc.php | 2 +- modules-available/statistics/pages/machine.inc.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules-available/statistics/inc/hardwareparserlegacy.inc.php b/modules-available/statistics/inc/hardwareparserlegacy.inc.php index 277f6d4a..2965a3fb 100644 --- a/modules-available/statistics/inc/hardwareparserlegacy.inc.php +++ b/modules-available/statistics/inc/hardwareparserlegacy.inc.php @@ -136,7 +136,7 @@ class HardwareParserLegacy public static function parsePci(string $data): array { - preg_match_all('/[a-f0-9:.]{7}\s+"(Class\s*)?(?[a-f0-9]{4})"\s+"(?[a-f0-9]{4})"\s+"(?[a-f0-9]{4})"/is', $data, $out, PREG_SET_ORDER); + preg_match_all('/[a-f0-9:.]{7}\s+"(Class\s*)?(?[a-f0-9]{4})"\s+"(?[a-f0-9]{4})"\s+"(?[a-f0-9]{4})".*(:?-r(?[0-9a-f]+))?/is', $data, $out, PREG_SET_ORDER); return $out; } diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php index 0d91b017..798a5a83 100644 --- a/modules-available/statistics/pages/machine.inc.php +++ b/modules-available/statistics/pages/machine.inc.php @@ -103,13 +103,14 @@ class SubPage 'locationid', $locations); $hw->addGlobalColumn('vendor'); $hw->addGlobalColumn('device'); + $hw->addGlobalColumn('rev'); $res = $hw->query(); foreach ($res as $row) { - $devId = $row['vendor'] . ':' . $row['device']; + $devId = $row['vendor'] . ':' . $row['device'] . ':' . $row['rev']; if (!isset($passthroughTypes[$devId])) { $passthroughTypes[$devId] = []; } - $passthroughTypes[$devId][] = $row['@PASSTHROUGH']; + $passthroughTypes[$devId][$row['@PASSTHROUGH']] = $row['@PASSTHROUGH']; } } // 2) Sort and mangle list @@ -125,8 +126,8 @@ class SubPage $pciLookup[$devId] = true; } // Passthrough enabled? - if (isset($passthroughTypes[$devId])) { - $item['pt'] = implode(', ', $passthroughTypes[$devId]); + if (isset($passthroughTypes[$devId . ':' . $item['rev']])) { + $item['pt'] = implode(', ', $passthroughTypes[$devId . ':' . $item['rev']]); } $class = $item['class']; if ($class === '0300' || $class === '0200' || $class === '0403' || !empty($item['pt'])) { -- cgit v1.2.3-55-g7522