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

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Nov 22 08:27:58 CET 2018


On 11/20/18 5:13 PM, Dominik Csapak wrote:
> this is for the gui to be able to select mediated devices

why not a scan/pci/{pci-id}/mdev API path? would make more sense reading the
API calls description and code. Please do so if you do not really have a strong
argument against, I do not want another strange API path set in stone.

It would maybe also make sense to have this local node HW stuff in it's own
directory, nodes/{node}/hardware/pci (and USB, even it's a bit late for that one).
Would distinct the storage (client) scan stuff from HW one.

> 
> 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;
> 





More information about the pve-devel mailing list