[pve-devel] [PATCH manager 1/6] Scan.pm: add pci scan api call

Dominik Csapak d.csapak at proxmox.com
Fri Nov 16 16:29:51 CET 2018


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

diff --git a/PVE/API2/Scan.pm b/PVE/API2/Scan.pm
index b67c1041..85c10d46 100644
--- a/PVE/API2/Scan.pm
+++ b/PVE/API2/Scan.pm
@@ -46,6 +46,7 @@ __PACKAGE__->register_method ({
 	    { method => 'usb' },
 	    { method => 'zfs' },
 	    { method => 'cifs' },
+	    { method => 'pci' },
 	    ];
 
 	return $res;
@@ -422,4 +423,99 @@ __PACKAGE__->register_method ({
 	return PVE::SysFSTools::scan_usb();
     }});
 
+__PACKAGE__->register_method ({
+    name => 'pciscan',
+    path => 'pci',
+    method => 'GET',
+    description => "List local PCI devices.",
+    protected => 1,
+    proxyto => "node",
+    permissions => {
+	check => ['perm', '/', ['Sys.Modify']],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    'filter-unusable' => {
+		type => 'boolean',
+		default => 1,
+		optional => 1,
+		description => "Control whether not pass-throughable devices,"
+			      ." can be passed through. Such devices include "
+			      ."Bridges, Memory controllers, Processors, etc.",
+	    },
+	    verbose => {
+		type => 'boolean',
+		default => 1,
+		optional => 1,
+		description => "If disabled, does only print the PCI IDs. "
+			      ."Otherwise, additional information like vendor "
+			      ."and device will be returned.",
+	    },
+	},
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    properties => {
+		id => {
+		    type => 'string',
+		    description => "The PCI ID.",
+		},
+		vendorid => {
+		    type => 'string',
+		    optional => 1,
+		},
+		vendor => {
+		    type => 'string',
+		    optional => 1,
+		},
+		deviceid => {
+		    type => 'string',
+		    optional => 1,
+		},
+		device => {
+		    type => 'string',
+		    optional => 1,
+		},
+		subsystem_vendorid => {
+		    type => 'string',
+		    optional => 1,
+		},
+		subsystem_vendor => {
+		    type => 'string',
+		    optional => 1,
+		},
+		subsystem_deviceid => {
+		    type => 'string',
+		    optional => 1,
+		},
+		subsystem_device => {
+		    type => 'string',
+		    optional => 1,
+		},
+		iommugroup => {
+		    type => 'integer',
+		    optional => 1,
+		},
+		mdev => {
+		    type => 'boolean',
+		    optional => 1,
+		    description => "If set, marks that the device is capable "
+				  ."of creating mediated devices.",
+		}
+	    },
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $filter = $param->{'filter-unusable'} // 1;
+	my $verbose = $param->{verbose} // 1;
+
+	return PVE::SysFSTools::lspci(undef, $filter, $verbose);
+    }});
+
 1;
-- 
2.11.0





More information about the pve-devel mailing list