From 12612b09ae4cadae5b654892fefd20ad24c5f5e3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 5 Feb 2016 08:46:34 +0100 Subject: [PATCH] Close #880: ability to show paused state via the CLI qm list and qm status both show suspended VMs as 'running' while the GUI's status summary shows them as 'paused'. This patch makes 'qm status' always request the full status and adds an optional '-full' parameter for 'qm list' to use a full status query to include the 'paused' state. (This is optional as it causes qmp requests to all running VMs.) --- PVE/API2/Qemu.pm | 7 ++++++- PVE/CLI/qm.pm | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index bf6f6fd..efac2c7 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -228,6 +228,11 @@ __PACKAGE__->register_method({ additionalProperties => 0, properties => { node => get_standard_option('pve-node'), + full => { + type => 'boolean', + optional => 1, + description => "Determine the full status of active VMs.", + }, }, }, returns => { @@ -244,7 +249,7 @@ __PACKAGE__->register_method({ my $rpcenv = PVE::RPCEnvironment::get(); my $authuser = $rpcenv->get_user(); - my $vmstatus = PVE::QemuServer::vmstatus(); + my $vmstatus = PVE::QemuServer::vmstatus(undef, $param->{full}); my $res = []; foreach my $vmid (keys %$vmstatus) { diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm index fdac3d5..0dd8159 100755 --- a/PVE/CLI/qm.pm +++ b/PVE/CLI/qm.pm @@ -119,7 +119,7 @@ __PACKAGE__->register_method ({ # test if VM exists my $conf = PVE::QemuServer::load_config ($param->{vmid}); - my $vmstatus = PVE::QemuServer::vmstatus($param->{vmid}); + my $vmstatus = PVE::QemuServer::vmstatus($param->{vmid}, 1); my $stat = $vmstatus->{$param->{vmid}}; if ($param->{verbose}) { foreach my $k (sort (keys %$stat)) { @@ -129,7 +129,7 @@ __PACKAGE__->register_method ({ print "$k: $v\n"; } } else { - my $status = $stat->{status} || 'unknown'; + my $status = $stat->{qmpstatus} || 'unknown'; print "status: $status\n"; } @@ -392,7 +392,7 @@ our $cmddef = { foreach my $rec (sort { $a->{vmid} <=> $b->{vmid} } @$vmlist) { printf "%10s %-20s %-10s %-10s %12.2f %-10s\n", $rec->{vmid}, $rec->{name}, - $rec->{status}, + $rec->{qmpstatus} || $rec->{status}, ($rec->{maxmem} || 0)/(1024*1024), ($rec->{maxdisk} || 0)/(1024*1024*1024), $rec->{pid}||0; -- 2.39.2