[pve-devel] [PATCH common 3/5] SysFSTools.pm: implement filter in lspci

Dominik Csapak d.csapak at proxmox.com
Fri Nov 16 16:17:48 CET 2018


use the first parameter as a filter for devices, like it is used

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/SysFSTools.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/PVE/SysFSTools.pm b/src/PVE/SysFSTools.pm
index 87568fb..660f94b 100644
--- a/src/PVE/SysFSTools.pm
+++ b/src/PVE/SysFSTools.pm
@@ -11,12 +11,14 @@ my $pcisysfs = "/sys/bus/pci";
 my $pciregex = "([a-f0-9]{4}):([a-f0-9]{2}):([a-f0-9]{2})\.([a-f0-9])";
 
 sub lspci {
+    my ($filter) = @_;
 
     my $devices = {};
 
     dir_glob_foreach("$pcisysfs/devices", $pciregex, sub {
             my (undef, undef, $bus, $slot, $function) = @_;
 	    my $id = "$bus:$slot";
+	    return if defined($filter) && $id ne $filter;
 	    my $res = { id => $id, function => $function};
 	    push @{$devices->{$id}}, $res;
     });
-- 
2.11.0





More information about the pve-devel mailing list