[pve-devel] [PATCH manager 1/4] add lock to /cluster/resources

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Mar 6 14:54:52 CET 2019


On 2/27/19 12:32 PM, Dominik Csapak wrote:
> this adds the lock to the resultset of a vm in /cluster/resources
> giving us the possibility of showing if a vm is locked/backed up/etc.
> 
> to achieve this, we load the config of the vm from pmxcfs. with this
> we have access to the full configuration of the vm and could add
> further fields if we want to
> 
> disadvantage is a rather small cpu/memory penalty, i benchmarked
> a virtual cluster with ~3000 vms:
> 
> it adds about 500ms the first time of the api call, and after that
> about 50-100ms, and adds about 2-4MB of memory per worker
off-list you told me that that the default resource API request needed
500ms per call without this, so it is a 10% - 20% increase, not quite
nothing, but if you consider the fact that we then have a lot more
information readily available it's also not really _that_ much.

If there are no objections by others I'll consider adding this, albeit
not yet 100% sure, but also in lack of a sane and better solution...

> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  PVE/API2/Cluster.pm | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
> index c72a075b..bf45186c 100644
> --- a/PVE/API2/Cluster.pm
> +++ b/PVE/API2/Cluster.pm
> @@ -299,7 +299,10 @@ __PACKAGE__->register_method({
>  	    foreach my $vmid (keys %$idlist) {
>  
>  		my $data = $idlist->{$vmid};
> +		my $typedir = $data->{type} eq 'qemu' ? 'qemu-server' : 'lxc';
> +		my $conf = PVE::Cluster::cfs_read_file("nodes/$data->{node}/$typedir/$vmid.conf");
>  		my $entry = PVE::API2Tools::extract_vm_stats($vmid, $data, $rrd);
> +		$entry->{lock} = $conf->{lock} if defined($conf->{lock});
>  		if (my $pool = $usercfg->{vms}->{$vmid}) {
>  		    $entry->{pool} = $pool;
>  		    if (my $pe = $pooldata->{$pool}) {
> 





More information about the pve-devel mailing list