[pve-devel] [PATCH qemu-server] vm status: guard get_memory_stat() call with eval

Fiona Ebner f.ebner at proxmox.com
Thu Jan 22 13:10:18 CET 2026


While in practice, it should be quite rare and unexpected for the
get_memory_stat() to fail, a single failing call should not fail the
whole pvestatd collection for VMs or even the single
'/qemu/{vmid}/status/current' API call for the affected VM, which e.g.
leads to the display for the VM in the UI being inaccessible.

One situation where it can happen is manually invoking the command
given by 'qm showcmd', because the process won't be part of the usual
systemd scope.

Fixes: 551c0078 ("fix #6935: vmstatus: use CGroup for host memory usage")
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 src/PVE/QemuServer.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index fc735aa3..7a0a2606 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -2589,7 +2589,8 @@ sub vmstatus {
         $d->{uptime} = int(($uptime - $pstat->{starttime}) / $cpuinfo->{user_hz});
 
         my $cgroup = PVE::QemuServer::CGroup->new($vmid);
-        my $cgroup_mem = $cgroup->get_memory_stat();
+        my $cgroup_mem = eval { $cgroup->get_memory_stat() } // {};
+        warn "unable to get memory stat for $vmid - $@" if $@;
         $d->{memhost} = $cgroup_mem->{mem} // 0;
 
         $d->{mem} = $d->{memhost}; # default to cgroup, balloon info can override this below
-- 
2.47.3





More information about the pve-devel mailing list