[pve-devel] [PATCH qemu-server 1/2] Close #880: ability to show paused state via the CLI

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Feb 5 08:46:34 CET 2016


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 39bd248..ce5c49e 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 747e540..b66d7bd 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.1.4





More information about the pve-devel mailing list