The vmstatus() function is used by pvestatd and needs to be fast.
However, the 'query-proxmox-support' querying is done sequentially for
each VM and each query has its own timeout (it's the default 5
seconds). If QMP is blocked for some reason for a single VM, that
already adds 5 seconds to the whole operation. Compared with the whole
stats querying queue, which is allowed to use 3 seconds in total, this
is rather extreme and needs to be fixed.

Back when commit 6891fd70 ("print query-proxmox-support result in
'full' status") was implemented, not all supported QEMU versions in
Proxmox VE implemented the 'query-proxmox-support' QMP command.
Because of this, the queue might be interrupted if ordering this
command too early. It still could've been ordered before the
'query-balloon' one, which also can fail. Nowadays, all supported QEMU
versions do implement the command and this just returns static
information which cannot fail (as long as QMP communication itself
works), so it can also be ordered at the beginning of the queue (after
the main 'query-status').

Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---

New in v2.

 src/PVE/QemuServer.pm | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index d6d0cb13..7d5ab718 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -2886,9 +2886,15 @@ sub vmstatus {
         $res->{$vmid}->{'running-qemu'} = $version;
     };
 
+    my $proxmox_support_cb = sub {
+        my ($vmid, $resp) = @_;
+        $res->{$vmid}->{'proxmox-support'} = $resp->{'return'} // {};
+    };
+
     my $statuscb = sub {
         my ($vmid, $resp) = @_;
 
+        $qmpclient->queue_cmd($vmid, $proxmox_support_cb, 
'query-proxmox-support');
         $qmpclient->queue_cmd($vmid, $blockstatscb, 'query-blockstats');
         $qmpclient->queue_cmd($vmid, $machinecb, 'query-machines');
         $qmpclient->queue_cmd($vmid, $versioncb, 'query-version');
@@ -2913,16 +2919,6 @@ sub vmstatus {
 
     $qmpclient->queue_execute(undef, 2);
 
-    foreach my $vmid (keys %$list) {
-        next if $opt_vmid && ($vmid ne $opt_vmid);
-        next if !$res->{$vmid}->{pid}; #not running
-
-        # we can't use the $qmpclient since it might have already aborted on
-        # 'query-balloon', but this might also fail for older versions...
-        my $qemu_support = eval { mon_cmd($vmid, "query-proxmox-support") };
-        $res->{$vmid}->{'proxmox-support'} = $qemu_support // {};
-    }
-
     foreach my $vmid (keys %$list) {
         next if $opt_vmid && ($vmid ne $opt_vmid);
         $res->{$vmid}->{qmpstatus} = $res->{$vmid}->{status} if 
!$res->{$vmid}->{qmpstatus};
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to