[pve-devel] [PATCH manager 2/6] Scan.pm: add mdev scan api call
Dominik Csapak
d.csapak at proxmox.com
Fri Nov 16 16:29:52 CET 2018
this is for the gui to be able to select mediated devices
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/API2/Scan.pm | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/PVE/API2/Scan.pm b/PVE/API2/Scan.pm
index 85c10d46..96d73b93 100644
--- a/PVE/API2/Scan.pm
+++ b/PVE/API2/Scan.pm
@@ -47,6 +47,7 @@ __PACKAGE__->register_method ({
{ method => 'zfs' },
{ method => 'cifs' },
{ method => 'pci' },
+ { method => 'mdev' },
];
return $res;
@@ -518,4 +519,51 @@ __PACKAGE__->register_method ({
return PVE::SysFSTools::lspci(undef, $filter, $verbose);
}});
+__PACKAGE__->register_method ({
+ name => 'mdevscan',
+ path => 'mdev',
+ method => 'GET',
+ description => "List mediated device types for given PCI device.",
+ protected => 1,
+ proxyto => "node",
+ permissions => {
+ check => ['perm', '/', ['Sys.Modify']],
+ },
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ pciid => {
+ type => 'string',
+ pattern => '(?:[0-9a-fA-F]{4}:)?[0-9a-fA-F]{2}:[0-9a-fA-F]{2}.[0-9a-fA-F]',
+ description => "The PCI ID to list the mdev types for."
+ },
+ },
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {
+ type => {
+ type => 'string',
+ description => "The name of the mdev type.",
+ },
+ available => {
+ type => 'integer',
+ description => "The number of still available instances of"
+ ." this type.",
+ },
+ description => {
+ type => 'string',
+ },
+ },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+
+ return PVE::SysFSTools::get_mdev_types($param->{pciid});
+ }});
+
1;
--
2.11.0
More information about the pve-devel
mailing list