[pve-devel] [PATCH manager 1/4] api: cluster/resources: add information about guest locks

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jun 11 06:02:23 CEST 2019


using the new get_guest_config_property helper from pve-cluster,
which allows us to get this info with relatively low overhead.

With a somewhat realistic setup of 303 guest configurations here my
API call timing changes from ~ 24 to 26 ms without this to 26 to 28
ms with this patch applied, which seems reasonable.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/API2/Cluster.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index bfdd9ad1..47d5a764 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -297,10 +297,17 @@ __PACKAGE__->register_method({
 
 	# we try to generate 'numbers' by using "$X + 0"
 	if (!$param->{type} || $param->{type} eq 'vm') {
+	    my $locked_vms = PVE::Cluster::get_guest_config_property('lock');
+
 	    foreach my $vmid (keys %$idlist) {
 
 		my $data = $idlist->{$vmid};
 		my $entry = PVE::API2Tools::extract_vm_stats($vmid, $data, $rrd);
+
+		if (defined(my $lock = $locked_vms->{$vmid}->{lock})) {
+		    $entry->{lock} = $lock;
+		}
+
 		if (my $pool = $usercfg->{vms}->{$vmid}) {
 		    $entry->{pool} = $pool;
 		    if (my $pe = $pooldata->{$pool}) {
-- 
2.20.1





More information about the pve-devel mailing list