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

Dominik Csapak d.csapak at proxmox.com
Wed Feb 27 12:32:33 CET 2019


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

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}) {
-- 
2.11.0





More information about the pve-devel mailing list