[pve-devel] [PATCH manager 2/6 v2] Scan.pm: add mdev scan api call

Dominik Csapak d.csapak at proxmox.com
Tue Nov 20 17:13:42 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 15c8b48a..7435915d 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;
@@ -546,4 +547,51 @@ __PACKAGE__->register_method ({
 	return PVE::SysFSTools::lspci($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