[pve-devel] [PATCH manager 06/11] Scan.pm: add pci scan api call
Dominik Csapak
d.csapak at proxmox.com
Thu Nov 15 15:30:52 CET 2018
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/API2/Scan.pm | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/PVE/API2/Scan.pm b/PVE/API2/Scan.pm
index 6cfb74e3..ec29ef24 100644
--- a/PVE/API2/Scan.pm
+++ b/PVE/API2/Scan.pm
@@ -7,6 +7,7 @@ use PVE::SafeSyslog;
use PVE::Storage;
use PVE::Storage::LVMPlugin;
use PVE::QemuServer::USB;
+use PVE::QemuServer::PCI;
use PVE::JSONSchema qw(get_standard_option);
use PVE::RESTHandler;
@@ -46,6 +47,7 @@ __PACKAGE__->register_method ({
{ method => 'usb' },
{ method => 'zfs' },
{ method => 'cifs' },
+ { method => 'pci' },
];
return $res;
@@ -422,4 +424,99 @@ __PACKAGE__->register_method ({
return PVE::QemuServer::USB::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::QemuServer::PCI::lspci(undef, $filter, $verbose);
+ }});
+
1;
--
2.11.0
More information about the pve-devel
mailing list