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.)
This commit is contained in:
Wolfgang Bumiller 2016-02-05 08:46:34 +01:00 committed by Dietmar Maurer
parent 521c52e09c
commit 12612b09ae
2 changed files with 9 additions and 4 deletions

View File

@ -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) {

View File

@ -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;