[pve-devel] [PATCH manager 07/11] Scan.pm: add mdev scan api call
Dominik Csapak
d.csapak at proxmox.com
Thu Nov 15 15:30:53 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 ec29ef24..5fcd5901 100644
--- a/PVE/API2/Scan.pm
+++ b/PVE/API2/Scan.pm
@@ -48,6 +48,7 @@ __PACKAGE__->register_method ({
{ method => 'zfs' },
{ method => 'cifs' },
{ method => 'pci' },
+ { method => 'mdev' },
];
return $res;
@@ -519,4 +520,51 @@ __PACKAGE__->register_method ({
return PVE::QemuServer::PCI::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::QemuServer::PCI::get_mdev_types($param->{pciid});
+ }});
+
1;
--
2.11.0
More information about the pve-devel
mailing list